Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _01.Train
- {
- class Program
- {
- static void Main(string[] args)
- {
- //You will be given a count of wagons in a train n. On the next n lines you will receive how many people are going to get on each wagon. At the end print the whole train and after that, on the next line, the sum of the people in the train.
- int n = int.Parse(Console.ReadLine());
- int[] train = new int[n];
- int sumPeople = 0;
- for (int i = 0; i < n; i++)
- {
- train[i] = int.Parse(Console.ReadLine());
- sumPeople += train[i];
- }
- for (int i = 0; i < n; i++)
- {
- Console.Write(train[i] + " ");
- }
- Console.WriteLine();
- Console.WriteLine(sumPeople);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement