View Code of Problem 36

/*
JLH统计法统计飞龙*/
#include <cstdio>
#include <map>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int x;
	scanf("%d",&x);
	while(x--){
		map<char,int>mp;
		string s;
		cin>>s;
		for(int i=0;i<s.size();i++){
			if(mp.find(s[i])==mp.end()){
				mp[s[i]]=1;
			}else{
				mp[s[i]]++;
			}
		}
		for(char c='A';c<='Z';c++){
			if(mp.find(c)!=mp.end()){
				printf("%d%c",mp[c],c);
			}
			
		}
		printf("\n");
	}
}

Double click to view unformatted code.


Back to problem 36