Advertisement
ElviraPetkova

bus

Dec 17th, 2018
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.03 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Problem5
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int numberOfPeople = int.Parse(Console.ReadLine());
  14.             int numberOfStops = int.Parse(Console.ReadLine()); //for
  15.  
  16.             for (int counterOfStops = 1; counterOfStops <= numberOfStops; counterOfStops++)
  17.             {
  18.                 int peopleOutBus = int.Parse(Console.ReadLine());
  19.                 int peopleInBus = int.Parse(Console.ReadLine());
  20.  
  21.                 if(counterOfStops % 2 != 0)
  22.                 {
  23.                     numberOfPeople = (numberOfPeople - peopleOutBus) + (peopleInBus + 2);
  24.                 }
  25.                 else
  26.                 {
  27.                     numberOfPeople = (numberOfPeople - peopleOutBus - 2) + peopleInBus;
  28.                 }
  29.             }
  30.  
  31.             Console.WriteLine("The final number of passengers is : {0}", numberOfPeople);
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement