View Code of Problem 36

#include <stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>

int main(){
	int t;
	char a[1000];
	scanf("%d",&t);
	while(t--){
		char z[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'};
		scanf("%s",&a);
		int count[26]={0};
		int len = strlen(a);
		for(int i = 0;i<len;i++){
			for(int j = 0;j<26;j++){
				if(a[i] == z[j]){
					count[j]++;
					break;
				}
			}
		}
		for(int j = 0;j<26;j++){
			if(count[j]!=0)
				printf("%d%c",count[j],z[j]);
		}
		
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 36