Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- ios_base::sync_with_stdio(false);
- cin.tie(0);
- int num = 30, taken = 0, round = 0;
- while(true){
- for(int i = 0; i < 3; i++, puts(""))
- for(int j = 1; j <= 10; j++)
- cout << (((i * 10 + j) <= num) ? 'O' : ' ');
- cout << "player " << (round % 2) + 1 << "'s turn : (1 ~ 4)\n";
- cin >> taken;
- if(taken < 1 || taken > 4){
- cout << "input error\n";
- continue;
- }
- num -= taken;
- if(num <= 0){
- cout << "player " << (1 ^ (round % 2)) + 1 << " is the winner!\n";
- break;
- }
- round++;
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment