Advertisement
LabiinfaCibGyti

laba8.17

Jan 9th, 2020
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <math.h>
  4. #include <string>
  5. using namespace std;
  6. int _tmain(int argc, _TCHAR* argv[])
  7. {
  8.     setlocale(0,"rus");
  9.     string s;
  10.     int i, k = 0, p1=0 ,p2=0,d=-1, max = -1;
  11.     getline(cin, s);
  12.     for (i=0;i<s.length();i++)
  13.     {
  14.         if (s[i]!=' ')
  15.         {
  16.             d++;
  17.             if (s[i]=='t')
  18.                     k++;
  19.             if (k>max)
  20.             {
  21.                 max=k;
  22.                 p1=i-d;
  23.                 p2=i;
  24.             }
  25.         }
  26.         else
  27.         {
  28.             k=0;
  29.             d=-1;
  30.         }  
  31.     }
  32.     for(i=p1;i<=p2;i++)
  33.     {
  34.         cout<<s[i];
  35.     }
  36.     cout<<endl;
  37.     cout<<"Кол-во букв T встречающихся в слове = "<<max<<endl;
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement