View Code of Problem 36

#include<bits/stdc++.h>

using namespace std;
        int main(){    
        	char a[1000];
        	int n;
        	scanf("%d\n",&n);
        	for(int i = 0;i<n;i++){
        		int num[100] = { };
        		gets(a);   //随便读一个字符串 
        		for(int i = 0;i<strlen(a);i++)num[a[i]]++; //取一个字符 放到对应的下标里  A 65
        		//  num下标代表写字母的阿斯克码  num内容就是这个字母出现了几次 
        		for(int i = 65;i<=91;i++){    //这里就是打印了 A 65 ----》 Z-90 
        			if(num[i]!=0){
        				cout<<num[i]<<(char)i;
        			}
        		}
        		cout<<endl;	   
        		    
        	}
        	return 0;
        }

Double click to view unformatted code.


Back to problem 36