i am taking an array of size 256 for all possible characters. i am incrementing the value at the index of the character. then i am printing the charcter followed by the value of array at that index. after printing i am setting it as zero so that it is not printed again
#include
#include
#include
using namespace std;
int main() {
int a[256]={0};
string s; cin>>s;
char x;
for (int i=0;i<s.length();i++)
{
x=s.at(i);
a[(int)x]++;
}
int y;
for (int i=0;i<s.length();i++)
{
x=s.at(i);
y=(int)x;
if(a[y]==0) continue;
cout<<x<<a[y];
a[y]=0;
}
return 0;
}