Advertisement
Spocoman

Cinema

Sep 16th, 2023
918
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.77 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     int seats, groupCount, income = 0;
  8.     cin >> seats;
  9.     cin.ignore();
  10.  
  11.     string command;
  12.     getline(cin, command);
  13.  
  14.     while (command != "Movie time!") {
  15.         groupCount = stoi(command);
  16.         if (groupCount > seats) {
  17.             break;
  18.         }
  19.  
  20.         seats -= groupCount;
  21.         income += groupCount * 5;
  22.  
  23.         if (groupCount % 3 == 0) {
  24.             income -= 5;
  25.         }
  26.        
  27.         getline(cin, command);
  28.     }
  29.  
  30.     if (command == "Movie time!") {
  31.         printf("There are %i seats left in the cinema.\n", seats);
  32.     }
  33.     else{
  34.         cout << "The cinema is full.\n";
  35.     }
  36.  
  37.     printf("Cinema income - %i lv.\n", income);
  38.  
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement