silentkiler029

Throwing cards away

Jun 22nd, 2020
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.14 KB | None | 0 0
  1. /*  BISMILLAHIR-RAHMANIR-RAHIM
  2.  ____________________________________
  3. |                                    |
  4. |       SHANTO_SUST_SWE-19_029       |
  5. |____________________________________|
  6. */
  7.  
  8. #include <bits/stdc++.h>
  9.  
  10. using namespace std;
  11.  
  12. #define ll long long
  13. #define pb push_back
  14. #define Pi acos(-1)
  15. #define r0 return 0
  16. #define endl "\n"
  17. #define show(x) cout << x << endl
  18. #define take(x) cin >> x
  19. #define debug 1
  20.  
  21. int main()
  22. {
  23.     int n, i, x;
  24.  
  25.     while(1){
  26.         cin >> n;
  27.         if (n == 0) r0;
  28.  
  29.         vector < int > v;
  30.  
  31.         for(i = 1; i <= n; i++) v.pb(i);
  32.  
  33.         cout << "Discarded cards:";
  34.         x = 1;
  35.  
  36.         while(x){
  37.             for(i = 0; i < v.size(); i++){
  38.                 cout << " " << v.front();
  39.                 if(v.size() > 2) cout << ",";
  40.                 v.erase(v.begin());
  41.                 v.pb(v.front());
  42.                 v.erase(v.begin());
  43.                 if(v.size() == 1){
  44.                     cout << endl << "Remaining card: " << v[0] << endl;
  45.                     x = 0;
  46.                     break;
  47.                 }
  48.             }
  49.         }
  50.     }
  51.  
  52.  
  53.     r0;
  54. }
  55.  
  56. //ALHAMDULILLAH
Advertisement
Add Comment
Please, Sign In to add comment