Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- #include <fstream>
- using namespace std;
- void ex_2()
- {
- int n,m;
- cin>>n;
- int a[n];
- for(int i=0;i<n;i++)
- {
- cin>>a[i];
- }
- cin>>m;
- int mn=1e9;
- int b[m];
- for(int i=0;i<m;i++)
- {
- cin>>b[i];
- if(b[i]<mn)
- {
- mn=b[i];
- }
- }
- int crt=0;
- for(int i=0;i<n;i++)
- {
- if(a[i]<mn)
- {
- crt++;
- }
- }
- cout<<crt<<endl;
- }
- void ex_3()
- {
- char s[10000000];
- // ifstream fin("bac.txt");
- cin.getline(s,201);
- //fin.close();
- int crt=-1;//final
- int x=-1;//fiecare interval
- int i=0;
- while(s)
- {
- if(s[i]==' ')
- {
- if(s[i-1]==s[i+1])
- {
- x++;
- }
- else{
- if(x>crt)
- {
- crt=x;
- x=-1;
- }
- }
- }
- i++;
- strcpy(s,s+1);
- }
- cout<<crt<<endl;
- }
- int main()
- {
- ex_3();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement