Advertisement
Spocoman

11. HappyCat Parking

Sep 12th, 2023
1,003
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     int days, hours;
  7.     cin >> days >> hours;
  8.  
  9.     double totalPrice = 0;
  10.  
  11.     for (int i = 1; i <= days; i++) {
  12.         double dayPrice = 0;
  13.  
  14.         for (int j = 1; j <= hours; j++) {
  15.  
  16.             if (i % 2 == 0 && j % 2 == 1) {
  17.                 dayPrice += 2.50;
  18.             }
  19.             else if (i % 2 == 1 && j % 2 == 0) {
  20.                 dayPrice += 1.25;
  21.             }
  22.             else {
  23.                 dayPrice++;
  24.             }
  25.         }
  26.         totalPrice += dayPrice;
  27.         printf("Day: %i - %.2f leva\n", i, dayPrice);
  28.     }
  29.     printf("Total: %.2f leva\n", totalPrice);
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement