Advertisement
Valantina

Bus/SampleExam

Jun 12th, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.88 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 stops = int.Parse(Console.ReadLine());
  11.             int count = 0;
  12.  
  13.             while (count != stops)
  14.             {
  15.                 int leftPassengers = int.Parse(Console.ReadLine());
  16.                 int newPassengers = int.Parse(Console.ReadLine());
  17.                 passengers -= leftPassengers;
  18.                 passengers += newPassengers;
  19.                 if (count % 2 == 0)
  20.                 {
  21.                     passengers += 2;
  22.                 }
  23.                 else
  24.                 {
  25.                     passengers -= 2;
  26.                 }
  27.  
  28.                 count++;
  29.             }
  30.             Console.WriteLine($"The final number of passengers is : {passengers}");
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement