Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Bus_Exam_24._11
- {
- class Program
- {
- static void Main(string[] args)
- {
- int countsOfPassagersIn = int.Parse(Console.ReadLine());
- int countOfStops = int.Parse(Console.ReadLine());
- // int leftPassagers = 0;
- int outPassagers = 0;
- int inPassagers = 0;
- for (int i = 1; i <= countOfStops; i++)
- {
- outPassagers = int.Parse(Console.ReadLine());
- inPassagers = int.Parse(Console.ReadLine());
- countsOfPassagersIn -= outPassagers;
- countsOfPassagersIn += inPassagers;
- // leftPassagers = (countsOfPassagersIn - outPassagers) + inPassagers;
- if (i % 2 == 1)
- {
- countsOfPassagersIn += 2;
- }
- else if (i % 2 == 0)
- {
- countsOfPassagersIn -= 2;
- }
- }
- Console.WriteLine($"The final number of passengers is : {countsOfPassagersIn}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment