Advertisement
Ychenik

Самое большое слово

Mar 23rd, 2019
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.99 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     char str[1000];
  8.     int i = 0;
  9.     int Max = 0;
  10.     int Maxpos = 0;
  11.     int nomer = 0;
  12.     cin.getline(str, 1000);
  13.     while(str[i] != 0)
  14.     {
  15.         if((str[i] >= 'A' && str[i] <= 'Z') || (str[i] >= 'a' && str[i] <='z'))
  16.         {
  17.             Maxpos++;
  18.         }
  19.         if (str[i + 1] < 'A' || (str[i + 1] > 'Z' && str[i + 1] < 'a') || str[i + 1] > 'z')
  20.         {
  21.             if((str[i] >= 'A' && str[i] <= 'Z') || (str[i] >= 'a' && str[i] <= 'z'))
  22.             {
  23.                 if(Maxpos > Max)
  24.                 {
  25.                     nomer = i + 1 - Maxpos;
  26.                     Max = Maxpos;
  27.                 }
  28.             }
  29.            }
  30.            if(str[i] < 'A' || (str[i] > 'Z' && str[i] < 'a') || str[i] >'z')
  31.            {
  32.                Maxpos = 0;
  33.            }
  34.         i++;
  35.     }
  36.     Maxpos = 0;
  37.     while(Maxpos < Max)
  38.     {
  39.         cout << str[nomer];
  40.         nomer++;
  41.         Maxpos++;
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement