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 _05.Bus
- {
- class Program
- {
- static void Main(string[] args)
- {
- int countPassengers = int.Parse(Console.ReadLine());
- int busStops = int.Parse(Console.ReadLine());
- // int count = 1;
- int sumPassengers = 0;
- int ednPassengers = 0;
- for (int i = 1; i <= busStops; i++)
- {
- int outPassengers = int.Parse(Console.ReadLine());
- int inPassengers = int.Parse(Console.ReadLine());
- if (i % 2 != 0)
- {
- sumPassengers -= outPassengers;
- sumPassengers += inPassengers + 2;
- }
- else
- {
- sumPassengers -= outPassengers;
- sumPassengers += inPassengers - 2;
- }
- }
- ednPassengers = countPassengers + sumPassengers;
- Console.WriteLine($"The final number of passengers is : {ednPassengers}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement