Advertisement
Threed90

05.Bus

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