View Code of Problem 36

#include <stdio.h>
#include <string.h>
int main(){
  int t;
  int i,j;
  int num,num1;
  scanf("%d",&t);
  int c[26]={0};
  char a[1000];
  char b[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'};
  while(t--){
	  num=0;
	  num1=0;
    scanf("%s",a);
    for(i=0;i<strlen(a);i++){
      for(j=0;j<26;j++){
		  if(a[i]==b[j]){
			  c[j]++;
			  
		  }

      }

    }
	for(j=0;j<26;j++)
	if(c[j]>=1)
		num++;
    for(j=0;j<26;j++){
      if(c[j]!=0){
		  num1++;
		  if(num1<num)
        printf("%d%c",c[j],b[j]);
		  else
			  printf("%d%c\n",c[j],b[j]);
      }
        
    }
	for(j=0;j<26;j++)
	c[j]=0;
    
  }
  
  
  
  
  return 0;
}

Double click to view unformatted code.


Back to problem 36