ralichka

05.More.Exercises.For.Loop-02.Hospital

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