SHARE
TWEET

Count each char in a String

a guest Jan 5th, 2011 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Count char by FamiHug 05.01.2011 14:13:09
  2. //Ver 1.0 chi nhap chu cai IN HOA VD: ABEAVDFSDEF
  3.  
  4. #include <stdio.h>
  5.  
  6. int main()
  7. {
  8.         int i,temp;
  9.         int cntr[26]={0};
  10.         while((temp=getchar())!='\n')
  11.                 cntr[(temp-'A')]++;
  12.         for(i=0;i<26;i++)
  13.                 if(cntr[i]>0) printf("%c_%d ",i+'A',cntr[i]);
  14.         return 0;
  15. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top