Advertisement
silvana1303

hospital

Apr 3rd, 2020
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.14 KB | None | 0 0
  1. using System;
  2.  
  3. namespace homeworkforloop
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int daysExamine = int.Parse(Console.ReadLine());
  10.  
  11.             int treatedPatients = 0;
  12.             int untreatedPatients = 0;
  13.             int doctors = 7;
  14.            
  15.  
  16.             for (int i = 1; i <= daysExamine; i++)
  17.             {
  18.                 int patientPerDay = int.Parse(Console.ReadLine());
  19.  
  20.                 if ((i % 3 == 0) && (untreatedPatients > treatedPatients))
  21.                 {
  22.                     doctors++;
  23.  
  24.                 }
  25.  
  26.                 if (patientPerDay <= doctors)
  27.                 {
  28.                     treatedPatients += patientPerDay;
  29.                 }
  30.                 if (patientPerDay > doctors)
  31.                 {
  32.                     untreatedPatients += (patientPerDay - doctors);
  33.                     treatedPatients += doctors;
  34.                 }
  35.  
  36.                
  37.  
  38.                
  39.             }
  40.  
  41.             Console.WriteLine($"Treated patients: {treatedPatients}.");
  42.             Console.WriteLine($"Untreated patients: {untreatedPatients}.");
  43.  
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement