View Code of Problem 36

#include<cstdio>
#include<string>
#include<map>
#include<iostream>
using namespace std;
int main(){
	int t;
	scanf("%d",&t);
	for(int i=0;i<t;i++){
		string str;
		cin>>str;
		int len=str.length();
		map<char,int> mp;
		for(int j=0;j<len;j++){
			mp[str[j]]++;
		}
		map<char,int>::iterator it=mp.begin();
		for(;it!=mp.end();it++){
			printf("%d%c",it->second,it->first);
		}
		printf("\n");
	}	
	return 0;
} 

Double click to view unformatted code.


Back to problem 36