Advertisement
Guest User

Untitled

a guest
Feb 18th, 2020
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. #include <fstream>
  2. #include <string>
  3. #include <vector>
  4.  
  5. using namespace std;
  6.  
  7. ifstream cin("cuvinte4.in");
  8. ofstream cout("cuvinte4.out");
  9.  
  10. struct cuv
  11. {
  12. int nr;
  13. string cuv;
  14. };
  15.  
  16. vector <cuv> v;
  17.  
  18. cuv a;
  19.  
  20. int x;
  21.  
  22. bool verif_a_b(string a,string b)
  23. {
  24. if(a.size()!=b.size())
  25. return false;
  26. for(int j=1;j<=a.size();j++)
  27. {
  28. char x=a[0];
  29. for(int z=0;z<a.size()-1;z++)
  30. a[z]=a[z+1];
  31. a[a.size()-1]=x;
  32. if(a==b and j<a.size())return true;
  33. }
  34. return false;
  35. }
  36.  
  37. int main()
  38. {
  39. while(1)
  40. {
  41. cin>>a.cuv;
  42. a.nr=++x;
  43. if(a.cuv[a.cuv.size()-1]=='!')
  44. {
  45. a.cuv.resize(a.cuv.size()-1);
  46. v.push_back(a);
  47. break;
  48. }
  49. v.push_back(a);
  50. }
  51. int r=-1;
  52. for(int i=0;i<v.size()-1;i++)
  53. {
  54. if(verif_a_b(v[i].cuv,v[i+1].cuv))
  55. {
  56. v.erase(v.begin()+i+1);
  57. if(r==-1)r=i+2;
  58. i--;
  59.  
  60. }
  61. }
  62. if(r!=-1)
  63. cout<<r;
  64. else cout<<0;
  65. cout<<endl;
  66. for(int i=0;i<v.size();i++)
  67. cout<<v[i].nr<<' ';
  68. return 0;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement