Advertisement
Spocoman

Balls

Sep 15th, 2023
628
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.19 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     int ballsNum;
  7.     cin >> ballsNum;
  8.  
  9.     int red = 0, orange = 0, yellow = 0, white = 0, black = 0, other = 0, totalPoints = 0;
  10.  
  11.     string ball;
  12.  
  13.     for (int i = 0; i < ballsNum; i++) {
  14.         cin >> ball;
  15.         if (ball == "red") {
  16.             totalPoints += 5;
  17.             red++;
  18.         }
  19.         else if (ball == "orange") {
  20.             totalPoints += 10;
  21.             orange++;
  22.         }
  23.         else if (ball == "yellow") {
  24.             totalPoints += 15;
  25.             yellow++;
  26.         }
  27.         else if (ball == "white") {
  28.             totalPoints += 20;
  29.             white++;
  30.         }
  31.         else if (ball == "black") {
  32.             totalPoints /= 2;
  33.             black++;
  34.         }
  35.         else {
  36.             other++;
  37.         }
  38.     }
  39.  
  40.     cout << "Total points: " << totalPoints << endl;
  41.     cout << "Red balls: " << red << endl;
  42.     cout << "Orange balls: " << orange << endl;
  43.     cout << "Yellow balls: " << yellow << endl;
  44.     cout << "White balls: " << white << endl;
  45.     cout << "Other colors picked: " << other << endl;
  46.     cout << "Divides from black balls: " << black << endl;
  47.  
  48.     return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement