Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int ballsNum;
- cin >> ballsNum;
- int red = 0, orange = 0, yellow = 0, white = 0, black = 0, other = 0, totalPoints = 0;
- string ball;
- for (int i = 0; i < ballsNum; i++) {
- cin >> ball;
- if (ball == "red") {
- totalPoints += 5;
- red++;
- }
- else if (ball == "orange") {
- totalPoints += 10;
- orange++;
- }
- else if (ball == "yellow") {
- totalPoints += 15;
- yellow++;
- }
- else if (ball == "white") {
- totalPoints += 20;
- white++;
- }
- else if (ball == "black") {
- totalPoints /= 2;
- black++;
- }
- else {
- other++;
- }
- }
- cout << "Total points: " << totalPoints << endl;
- cout << "Red balls: " << red << endl;
- cout << "Orange balls: " << orange << endl;
- cout << "Yellow balls: " << yellow << endl;
- cout << "White balls: " << white << endl;
- cout << "Other colors picked: " << other << endl;
- cout << "Divides from black balls: " << black << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement