Advertisement
Spocoman

01. Cinema

Sep 5th, 2023
686
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.96 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     string screeningType;
  7.     cin >> screeningType;
  8.  
  9.     int rows, columns;
  10.     cin >> rows >> columns;
  11.  
  12.     double income = rows * columns;
  13.  
  14.     if (screeningType == "Premiere") {
  15.         income *= 12;
  16.     }
  17.     else if (screeningType == "Normal") {
  18.         income *= 7.5;
  19.     }
  20.     else {
  21.         income *= 5;
  22.     }
  23.  
  24.     cout.setf(ios::fixed);
  25.     cout.precision(2);
  26.  
  27.     cout << income << " leva" << endl;
  28.  
  29.     return 0;
  30. }
  31.  
  32. Решение с тернарен оператор:
  33.  
  34. #include <iostream>
  35.  
  36. using namespace std;
  37.  
  38. int main() {
  39.     string screeningType;
  40.     cin >> screeningType;
  41.  
  42.     int rows, columns;
  43.     cin >> rows >> columns;
  44.  
  45.     double income =
  46.         screeningType == "Premiere" ? 12 :
  47.         screeningType == "Normal" ? 7.50 : 5;
  48.  
  49.     cout.setf(ios::fixed);
  50.     cout.precision(2);
  51.  
  52.     cout << rows * columns * income << " leva" << endl;
  53.  
  54.     return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement