Advertisement
Spocoman

Bus

Oct 9th, 2023
932
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.82 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 passengers = int.Parse(Console.ReadLine());
  10.             int stations = int.Parse(Console.ReadLine());
  11.  
  12.             for (int i = 1; i <= stations; i++)
  13.             {
  14.                 int outputPassengers = int.Parse(Console.ReadLine());
  15.                 int inputPassengers = int.Parse(Console.ReadLine());
  16.  
  17.                 passengers += inputPassengers - outputPassengers;
  18.  
  19.                 if (i % 2 == 1)
  20.                 {
  21.                     passengers += 2;
  22.                 }
  23.                 else
  24.                 {
  25.                     passengers -= 2;
  26.                 }
  27.             }
  28.  
  29.             Console.WriteLine($"The final number of passengers is : {passengers}");
  30.         }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement