Krasimir_Slavov

Bus

Oct 29th, 2018
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.27 KB | None | 0 0
  1. https://softuni.bg/downloads/svn/programming-basics/2018-02/Exam/Problem%2004%20-%20Bus.pdf
  2.  
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8.  
  9. namespace Exam_Bus
  10. {
  11.     class Program
  12.     {
  13.         static void Main(string[] args)
  14.         {
  15.             int passenger = int.Parse(Console.ReadLine());
  16.             int station = int.Parse(Console.ReadLine());
  17.             int countPassenger = int.Parse(Console.ReadLine());
  18.  
  19.             int countPassArrived = 0;
  20.             int countPassengerIn = 0;
  21.             int countPassengerOut = 0;
  22.             int countPassArrivedEven = 0;
  23.             int countPassArrivedOdd = 0;
  24.  
  25.             if (countPassenger % 1 == 0)
  26.             {
  27.                 countPassenger = countPassengerIn;
  28.                 countPassArrivedOdd = passenger + countPassengerIn + 2;
  29.             }
  30.             else if (countPassenger % 2 == 0)
  31.             {
  32.                 countPassenger = countPassengerOut;
  33.                 countPassArrivedEven = passenger - countPassengerOut - 2;
  34.             }
  35.             countPassArrived = countPassArrivedOdd + countPassArrivedEven;
  36.             Console.WriteLine($"The final number of passengers is : {countPassArrived}");
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment