Advertisement
Guest User

footballResults

a guest
Apr 2nd, 2020
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <cmath>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     int matches = 0, win = 0, lose = 0, draw = 0;
  10.  
  11.     while (matches < 3)
  12.     {
  13.         string result;
  14.         cin >> result;     
  15.        
  16.         char ch = result[0] - 48; char ch1 = result[2] - 48;
  17.  
  18.             int team = ch; int team1 = ch1;
  19.  
  20.             if (team > team1){
  21.                 win++;
  22.             }
  23.             else if(team < team1){
  24.                 lose++;
  25.             }
  26.             else{
  27.                 draw++;
  28.             }  
  29.  
  30.         matches++;
  31.     }
  32.     cout << "Team won " << win << " games.\n";
  33.  
  34.     cout << "Team lost " << lose << " games.\n";
  35.    
  36.     cout << "Drawn games: " << draw;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement