Advertisement
madidino

teza1

Nov 12th, 2023 (edited)
520
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.07 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. #include <fstream>
  4. using namespace std;
  5.  
  6. void ex_2()
  7. {
  8.    int n,m;
  9.    cin>>n;
  10.    int a[n];
  11.    for(int i=0;i<n;i++)
  12.    {
  13.        cin>>a[i];
  14.    }
  15.    cin>>m;
  16.    int mn=1e9;
  17.   int b[m];
  18.    for(int i=0;i<m;i++)
  19.    {
  20.        cin>>b[i];
  21.        if(b[i]<mn)
  22.        {
  23.            mn=b[i];
  24.        }
  25.    }
  26.    int crt=0;
  27.    for(int i=0;i<n;i++)
  28.    {
  29.        if(a[i]<mn)
  30.        {
  31.            crt++;
  32.        }
  33.    }
  34.    cout<<crt<<endl;
  35. }
  36. void ex_3()
  37. {
  38.     char s[10000000];
  39.    // ifstream fin("bac.txt");
  40.     cin.getline(s,201);
  41.     //fin.close();
  42.     int crt=-1;//final
  43.     int x=-1;//fiecare interval
  44.     int i=0;
  45.     while(s)
  46.     {
  47.         if(s[i]==' ')
  48.         {
  49.             if(s[i-1]==s[i+1])
  50.             {
  51.                 x++;
  52.             }
  53.             else{
  54.                 if(x>crt)
  55.                 {
  56.                     crt=x;
  57.                     x=-1;
  58.                 }
  59.             }
  60.         }
  61.         i++;
  62.         strcpy(s,s+1);
  63.     }
  64.     cout<<crt<<endl;
  65. }
  66. int main()
  67. {
  68.     ex_3();
  69.     return 0;
  70. }
  71.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement