Advertisement
AndriikoM

Лекція 4, завдання 4

Nov 6th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.08 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3.  
  4. using namespace std;
  5.  
  6. int main ()
  7.  
  8. {
  9.     char f;
  10.     char g;
  11.     int c=0;
  12.     string str;
  13.     cout << "Vvedit' ryadok sliv:"<< endl;
  14.     getline(cin,str);
  15.     for (int i=0; i<str.size(); i++)
  16.     {
  17.         if (str[i]>=97 && str[i]<=122)
  18.         {
  19.             str[i]-=32;
  20.         }
  21.     }
  22.     for (int i=0; i<str.size(); i++)
  23.     {
  24.         for (int j=0; j<str.size()-1; j++)
  25.         {
  26.             if (str[j] > str[j+1])
  27.             {
  28.                 int t = str[j];
  29.                 str[j]=str[j+1];
  30.                 str[j+1]=t;
  31.             }
  32.         }
  33.     }
  34.     for(int i=0;i<str.size();i++)
  35.     {
  36.         if (str[i]>=65 && str[i]<=90)
  37.         {
  38.             f = str[i];
  39.             g=str[i+1];
  40.             if(f!=g)
  41.             {
  42.                 for(int v=0;v<str.size();v++)
  43.                 {
  44.                     if(str[v]==f)
  45.                     {
  46.                         c++;
  47.                     }
  48.                 }
  49.                 cout<<f<<" = "<<c<<endl;
  50.                 c=0;
  51.             }
  52.         }
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement