Advertisement
desislava_topuzakova

06. Vet Parking

Jul 18th, 2020
1,000
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.55 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO.IsolatedStorage;
  4. using System.Linq;
  5.  
  6. namespace _02._Odd_Occurrences
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             int days = int.Parse(Console.ReadLine());
  13.             int hours = int.Parse(Console.ReadLine());
  14.             //1. преминем (обходим всички)
  15.  
  16.             double totalSum = 0; //обща сума
  17.             for (int day = 1; day <= days; day++)
  18.             {
  19.                 //какво искаме да се случи за всеки един ден
  20.                 double sum = 0; //сума за деня
  21.                 for (int hour = 1; hour <= hours; hour++)
  22.                 {
  23.                     //четен ден и нечетен час
  24.                     if (day % 2 == 0 && hour % 2 == 1)
  25.                     {
  26.                         sum += 2.50;
  27.                         totalSum += 2.50;
  28.                     }
  29.                     //нечетен ден и четен час
  30.                     else if (day % 2 == 1 && hour % 2 == 0)
  31.                     {
  32.                         sum += 1.25;
  33.                         totalSum += 1.25;
  34.                     }
  35.                     else
  36.                     {
  37.                         sum += 1;
  38.                         totalSum += 1;
  39.                     }
  40.                 }
  41.  
  42.                 Console.WriteLine($"Day: {day} - {sum:F2} leva");
  43.             }
  44.             Console.WriteLine($"Total: {totalSum:F2} leva");
  45.  
  46.         }
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement