Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* BISMILLAHIR-RAHMANIR-RAHIM
- ____________________________________
- | |
- | SHANTO_SUST_SWE-19_029 |
- |____________________________________|
- */
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define pb push_back
- #define Pi acos(-1)
- #define r0 return 0
- #define endl "\n"
- #define show(x) cout << x << endl
- #define take(x) cin >> x
- #define debug 1
- int main()
- {
- int n, i, x;
- while(1){
- cin >> n;
- if (n == 0) r0;
- vector < int > v;
- for(i = 1; i <= n; i++) v.pb(i);
- cout << "Discarded cards:";
- x = 1;
- while(x){
- for(i = 0; i < v.size(); i++){
- cout << " " << v.front();
- if(v.size() > 2) cout << ",";
- v.erase(v.begin());
- v.pb(v.front());
- v.erase(v.begin());
- if(v.size() == 1){
- cout << endl << "Remaining card: " << v[0] << endl;
- x = 0;
- break;
- }
- }
- }
- }
- r0;
- }
- //ALHAMDULILLAH
Advertisement
Add Comment
Please, Sign In to add comment