View Code of Problem 36

#include<stdio.h>
#include<string.h>
int main(){
	int n;
	scanf("%d",&n);
	while(n--){
		//算法核心就是利用大写字母的ASCII码
		char a[1000];
		int b[26]={0};//千万记得要给数组初始化 
		int i; 
		scanf("%s",a);
		for( i=0;i<strlen(a);i++){
				b[a[i]-65]++;	
		} 
		for( i=0;i<26;i++){
			if(b[i]!=0){  //0不能输出 
			printf("%d%c",b[i],i+65);	
			}
			
		}
		printf("\n");
	} 
	
	
	return 0;
}

Double click to view unformatted code.


Back to problem 36