Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- string screeningType;
- cin >> screeningType;
- int rows, columns;
- cin >> rows >> columns;
- double income = rows * columns;
- if (screeningType == "Premiere") {
- income *= 12;
- }
- else if (screeningType == "Normal") {
- income *= 7.5;
- }
- else {
- income *= 5;
- }
- cout.setf(ios::fixed);
- cout.precision(2);
- cout << income << " leva" << endl;
- return 0;
- }
- Решение с тернарен оператор:
- #include <iostream>
- using namespace std;
- int main() {
- string screeningType;
- cin >> screeningType;
- int rows, columns;
- cin >> rows >> columns;
- double income =
- screeningType == "Premiere" ? 12 :
- screeningType == "Normal" ? 7.50 : 5;
- cout.setf(ios::fixed);
- cout.precision(2);
- cout << rows * columns * income << " leva" << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement