Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <list>
- #include<iterator>
- #include<string>
- using namespace std;
- list<string> list1;
- //list<string> list2;
- int main()
- {
- int n,i,nr;
- string x;
- cin>>n;
- for (i=1; i<=n; i++)
- {
- cin>>x;
- list1.push_back(x);
- }
- list<string> list2;
- //list2.clear();
- cin>>nr;
- // for(list<string>::iterator it2 = list1.begin(); it2!=list1.end(); it2++)
- // cout<<*it2<<"\n";
- int k=0;
- list<string>::iterator it = list1.begin();
- // cout<<it;
- while(list1.size()!=1)
- {
- // for(list<string>::iterator it = list1.begin(); it!=list1.end(); it++)
- {
- k++;
- // it++;
- if(k==nr)
- {
- list2.push_back(*it);
- list1.erase(it);
- k=0;
- // cout<<*it<<" ";
- }
- // cout<<*it<<" ";
- //else
- // k++;
- // it++;
- // cout<<*it<<" ";
- if((++it)==list1.end()) it=list1.begin();
- }
- // it=list1.begin();
- }
- cout<<"lista: \n";
- for(list<string>::iterator it3 = list1.begin(); it3!=list1.end(); it3++)
- cout<<*it3<<"\n";
- cout<<"q: \n";
- for(list<string>::iterator it2 = list2.begin(); it2!=list2.end(); it2++)
- cout<<*it2<<"\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement