Guest User

Untitled

a guest
Jul 17th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main() {
  4. ios_base::sync_with_stdio(false);
  5. cin.tie(0);
  6. int num = 30, taken = 0, round = 0;
  7. while(true){
  8. for(int i = 0; i < 3; i++, puts(""))
  9. for(int j = 1; j <= 10; j++)
  10. cout << (((i * 10 + j) <= num) ? 'O' : ' ');
  11. cout << "player " << (round % 2) + 1 << "'s turn : (1 ~ 4)\n";
  12. cin >> taken;
  13. if(taken < 1 || taken > 4){
  14. cout << "input error\n";
  15. continue;
  16. }
  17. num -= taken;
  18. if(num <= 0){
  19. cout << "player " << (1 ^ (round % 2)) + 1 << " is the winner!\n";
  20. break;
  21. }
  22. round++;
  23. }
  24. return 0;
  25. }
Add Comment
Please, Sign In to add comment