Advertisement
pablo7890

zliczanie znakow - bez conio.h

Apr 27th, 2013
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     char napis[100];
  6.     int ilosci[26] = {};
  7.     int i=0;
  8.  
  9.     int n;
  10.     cin >> n;
  11.  
  12.     for (int i=0; i<n; i++)
  13.     {
  14.         cin >> napis;
  15.         for(int j=0; j<100; j++)
  16.         {
  17.             ilosci[napis[j] - 97] ++;
  18.         }
  19.     }
  20.  
  21.     for(i = 0;i<26;i++)
  22.     {
  23.         if(ilosci[i])
  24.             cout << (char)(i + 97) << " " << ilosci[i]<<endl;;
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement