Advertisement
DarkDreameMU

Untitled

Feb 24th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. //NOW WE CHECK HOW MANY CHARACTER IN STRING AND HOW MANY TIMES IT APPEARS
  5.  
  6. int main()
  7. {
  8. int freq[128];
  9. string str;
  10. getline(cin,str);
  11. int siz=str.size();
  12. for(int i=0; i<128; i++)
  13. {
  14. freq[i]=0;
  15. }
  16. for(int i=0; i<siz; i++)//class
  17. {
  18. int t=str[i];
  19. freq[t]++;
  20. }
  21. for(int i=0; i<128; i++)
  22. {
  23. if(freq[i]!=0)
  24. {
  25. printf("%c ",i);
  26. printf("%d\n",freq[i]);
  27. }
  28. }
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement