Advertisement
pablo7890

zliczanie znakow

Apr 27th, 2013
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.84 KB | None | 0 0
  1. #include <cstdio>
  2. #include <conio.h>
  3. #include <string>
  4. #include <iostream>
  5.  
  6. using namespace std;
  7.  
  8. const int n = 26;
  9.  
  10. char zn = 'a';
  11.  
  12. int main()
  13. {
  14.     int koleczka;
  15.  
  16.     cin >> koleczka;
  17.  
  18.     int t[n];
  19.  
  20.     for (int i=0; i<n; i++)
  21.     {
  22.         t[i] =0;
  23.     }
  24.  
  25.     char *tekst;
  26.     char cc;
  27.  
  28.     for (int i=0; i<koleczka; i++)
  29.     {
  30.         do
  31.         {
  32.             if (cc <= 'z')
  33.             {
  34.                 if ( cc >= 'a') t[ cc -'a']++;
  35.             }
  36.  
  37.             cc = getch();
  38.             printf("%c", cc);
  39.  
  40.         } while (cc!=13);
  41.         if (i != koleczka-1)
  42.         {
  43.             cout << endl;
  44.         }
  45.     }
  46.  
  47.     cout << endl;
  48.  
  49.     for (int i=0; i<n; i++)
  50.     {
  51.         if (t[i]!=0)
  52.         {
  53.             cout << zn << " " << t[i] << endl;
  54.         }
  55.         zn++;
  56.     }
  57.  
  58.     return 0;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement