View Code of Problem 36

#include<stdio.h>

void count(char str[100])
{
char example[27]={0,'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 number[27]={0};
scanf("%s",str);   
for(int i=0;str[i]!='\0';i++)
	{ for(int j=1;j<=26;j++)
		{if (str[i]==example[j])  number[j]++;		}
	}
for(int k=1;k<=26;k++)
{
if (number[k]>0)
printf("%d%c",number[k],example[k]);
}
}

void main()
{ 
	char str[1000];
	int T,i=1;
scanf("%d",&T);
for(i=1;i<=T;i++)
{scanf("%d",&str);
count(str);
printf("\n");
}


}

Double click to view unformatted code.


Back to problem 36