Advertisement
Ro_ro400_

Untitled

Dec 13th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.22 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     int curp = 0;
  7.     int curl = 0;
  8.     int maxp = 0;
  9.     int maxl = 0;
  10.     int size = 80;
  11.     char str[size];
  12.     cin.getline(str,size);
  13.     if((str[0] >= 'a' && str[0] <= 'z') || (str[0] >= 'A' && str[0] <= 'Z'))
  14.     {
  15.         curl = 1;
  16.     }
  17.     for(int i = 1 ; str[i] != 0; i++)
  18.     {
  19.         if(!(str[i] >= 'a' && str[i] <= 'z'))
  20.         {
  21.             if(str[i+1] >= 'a' && str[i+1] <= 'z')
  22.             {
  23.                 curp = i+1;
  24.             }
  25.         }
  26.         else
  27.         {
  28.             if(str[i-1] >= 'a' && str[i-1] <= 'z')
  29.             {
  30.                 curl++;
  31.             }
  32.             else if(str[i] >= 'a' && str[i] <= 'z')
  33.             {
  34.                 if(!(str[i-1] >= 'a' && str[i-1] <= 'z'))
  35.                 {
  36.                     curl = 1;
  37.                 }
  38.             }
  39.         }
  40.         if(!(str[i] >= 'a' && str[i] <= 'z'))
  41.         {
  42.             if(str[i-1] >= 'a' && str[i-1] <= 'z')
  43.             {
  44.                 curl = i -1;
  45.             }
  46.         }
  47.         if(maxl<curl)
  48.         {
  49.             maxl = curl;
  50.             maxp = curp;
  51.         }
  52.     }
  53. for(int p = 0; p <= maxl; p++)
  54. {        
  55.  cout<<str[maxp+p];  
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement