Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main() {
- string player1, player2, command;
- cin >> player1 >> player2;
- cin.ignore();
- getline(cin, command);
- int card1, card2, point1 = 0, point2 = 0;
- while (command != "End of game") {
- card1 = stoi(command);
- cin >> card2;
- if (card1 > card2) {
- point1 += card1 - card2;
- }
- else if (card1 < card2) {
- point2 += card2 - card1;
- }
- else {
- cin >> card1 >> card2;
- cout << "Number wars!\n";
- if (card1 > card2){
- cout << player1 << " is winner with " << point1 << " points\n";
- }
- else {
- cout << player2 << " is winner with " << point2 << " points\n";
- }
- break;
- }
- cin.ignore();
- getline(cin, command);
- }
- if (command == "End of game") {
- cout << player1 << " has " << point1 << " points\n"
- << player2 << " has " << point2 << " points\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement