Advertisement
abushik

Bus

Dec 14th, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.84 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Bus
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int passangersinBus = int.Parse(Console.ReadLine());
  10.             int countStops = int.Parse(Console.ReadLine());
  11.  
  12.  
  13.             for (int i = 0; i < countStops; i++)
  14.             {
  15.                 int passangersOut = int.Parse(Console.ReadLine());
  16.                 int passangersIn = int.Parse(Console.ReadLine());
  17.  
  18.  
  19.                 if (i! % 2 == 0)
  20.                 {
  21.  
  22.                     passangersinBus += passangersIn + 2 - passangersOut;
  23.  
  24.                 }
  25.                 else
  26.                 {
  27.                     passangersinBus += passangersIn - passangersOut - 2;
  28.                 }
  29.             }
  30.             Console.WriteLine($"The final number of passengers is : {passangersinBus}");
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement