Spocoman

02. Hospital(with ternary operator)

Nov 20th, 2021 (edited)
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.75 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Hospital
  4. {
  5.     class Program
  6.     {
  7.         static void Main()
  8.         {
  9.             int period = int.Parse(Console.ReadLine());
  10.             int treated = 0;
  11.             int untreated = 0;
  12.             int doctors = 7;
  13.  
  14.             for (int i = 1; i <= period; i++)
  15.             {
  16.                 int patients = int.Parse(Console.ReadLine());
  17.  
  18.                 _ = untreated > treated && i % 3 == 0 ? doctors++ : doctors;
  19.                 _ = patients > doctors ? treated += doctors : treated += patients;
  20.                 _ = patients > doctors ? untreated += patients - doctors : untreated;
  21.             }
  22.             Console.WriteLine($"Treated patients: {treated}.\nUntreated patients: {untreated}.");
  23.         }
  24.     }
  25. }
Add Comment
Please, Sign In to add comment