View Code of Problem 36

#include<stdio.h>
#include<string.h>
int main(){    
	char a[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
	int n;
	scanf("%d\n",&n);
	for(int i = 0;i<n;i++){
		int num[100] = { };
		char k[1010];
		gets(k);    
		for(int i = 0;i<strlen(k);i++){
			for(int j = 0;j<26;j++){    
				if(a[j]==k[i]){
					num[j]++;
			}
		}	
	}
		for(int i = 0;i < 26;i++){
			if(num[i]!= 0){
				printf("%d%c",num[i],a[i]);
			}
		}
		printf("\n");
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 36