alexbancheva

Bus

Feb 23rd, 2020
308
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 Bus_Exam_24._11
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int countsOfPassagersIn = int.Parse(Console.ReadLine());
  10.             int countOfStops = int.Parse(Console.ReadLine());
  11.             // int leftPassagers = 0;
  12.             int outPassagers = 0;
  13.             int inPassagers = 0;
  14.  
  15.             for (int i = 1; i <= countOfStops; i++)
  16.             {
  17.                 outPassagers = int.Parse(Console.ReadLine());
  18.                 inPassagers = int.Parse(Console.ReadLine());
  19.  
  20.                 countsOfPassagersIn -= outPassagers;
  21.                 countsOfPassagersIn += inPassagers;
  22.  
  23.               //  leftPassagers = (countsOfPassagersIn - outPassagers) + inPassagers;
  24.  
  25.                 if (i % 2 == 1)
  26.                 {
  27.                     countsOfPassagersIn += 2;
  28.                 }
  29.                 else if (i % 2 == 0)
  30.                 {
  31.                     countsOfPassagersIn -= 2;
  32.                 }
  33.                
  34.             }
  35.             Console.WriteLine($"The final number of passengers is : {countsOfPassagersIn}");
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment