Advertisement
tissiana

Train

Oct 14th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.90 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 Train
  8. {
  9.     class Program
  10.     {
  11.         static void Main()
  12.         {
  13.             int wagonsCount = int.Parse(Console.ReadLine());
  14.  
  15.             int[] peopleCount = new int[wagonsCount];
  16.             int totalPeopleCount = 0;
  17.             string passangers = "";
  18.             for (int i = 0; i < wagonsCount; i++)
  19.             {
  20.                 int people = int.Parse(Console.ReadLine());
  21.                 peopleCount[i] = people;
  22.                 totalPeopleCount += people;
  23.               passangers =   passangers+ peopleCount[i] + " ";
  24.  
  25.  
  26.                 if (i == wagonsCount - 1)
  27.                 {
  28.                     Console.WriteLine(passangers);
  29.                     Console.WriteLine(totalPeopleCount);
  30.                 }    
  31.             }
  32.  
  33.  
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement