Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <string>
- #include <vector>
- using namespace std;
- ifstream cin("cuvinte4.in");
- ofstream cout("cuvinte4.out");
- struct cuv
- {
- int nr;
- string cuv;
- };
- vector <cuv> v;
- cuv a;
- int x;
- bool verif_a_b(string a,string b)
- {
- if(a.size()!=b.size())
- return false;
- for(int j=1;j<=a.size();j++)
- {
- char x=a[0];
- for(int z=0;z<a.size()-1;z++)
- a[z]=a[z+1];
- a[a.size()-1]=x;
- if(a==b and j<a.size())return true;
- }
- return false;
- }
- int main()
- {
- while(1)
- {
- cin>>a.cuv;
- a.nr=++x;
- if(a.cuv[a.cuv.size()-1]=='!')
- {
- a.cuv.resize(a.cuv.size()-1);
- v.push_back(a);
- break;
- }
- v.push_back(a);
- }
- int r=-1;
- for(int i=0;i<v.size()-1;i++)
- {
- if(verif_a_b(v[i].cuv,v[i+1].cuv))
- {
- v.erase(v.begin()+i+1);
- if(r==-1)r=i+2;
- i--;
- }
- }
- if(r!=-1)
- cout<<r;
- else cout<<0;
- cout<<endl;
- for(int i=0;i<v.size();i++)
- cout<<v[i].nr<<' ';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement