Advertisement
dancheff

Untitled

Jan 19th, 2021
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.73 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8.     int matches = 0, win = 0, lose = 0, draw = 0;
  9.  
  10.     while (matches < 3) {
  11.         string result;
  12.         cin >> result;      
  13.        
  14.         char ch1 = result[0] - 48; char ch2 = result[2] - 48;
  15.  
  16.             int teamA = ch1; int teamB = ch2;
  17.  
  18.             if (teamA > teamB) {
  19.                 win++;
  20.             } else if(teamA < teamB) {
  21.                 lose++;
  22.             } else {
  23.                 draw++;
  24.             }  
  25.  
  26.         matches++;
  27.     }
  28.     cout << "Team won " << win << " games." << endl;
  29.  
  30.     cout << "Team lost " << lose << " games." << endl;
  31.    
  32.     cout << "Drawn games: " << draw << endl;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement