Advertisement
Spocoman

Football Results

Sep 19th, 2023 (edited)
966
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     int won = 0, lost = 0, drawn = 0;
  7.  
  8.     string gameResult;
  9.  
  10.     for (int i = 0; i < 3; i++) {
  11.         cin >> gameResult;
  12.  
  13.         int teamOneResult = (int)gameResult[0];
  14.         int teamTwoResult = (int)gameResult[2];
  15.  
  16.         if (teamOneResult > teamTwoResult) {
  17.             won++;
  18.         }
  19.         else if (teamTwoResult > teamOneResult) {
  20.             lost++;
  21.         }
  22.         else {
  23.             drawn++;
  24.         }
  25.     }
  26.  
  27.     cout << "Team won " << won << " games.\n"
  28.         << "Team lost " << lost << " games.\n"
  29.         << "Drawn games: " << drawn << endl;
  30.  
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement