Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Problem5
- {
- class Program
- {
- static void Main(string[] args)
- {
- int numberOfPeople = int.Parse(Console.ReadLine());
- int numberOfStops = int.Parse(Console.ReadLine()); //for
- for (int counterOfStops = 1; counterOfStops <= numberOfStops; counterOfStops++)
- {
- int peopleOutBus = int.Parse(Console.ReadLine());
- int peopleInBus = int.Parse(Console.ReadLine());
- if(counterOfStops % 2 != 0)
- {
- numberOfPeople = (numberOfPeople - peopleOutBus) + (peopleInBus + 2);
- }
- else
- {
- numberOfPeople = (numberOfPeople - peopleOutBus - 2) + peopleInBus;
- }
- }
- Console.WriteLine("The final number of passengers is : {0}", numberOfPeople);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement