Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Disclaimer: The creator of 'C# Shell (C# Offline Compiler)' is in no way responsible for the code posted by any user.
- using System;
- using System.IO;
- using System.Linq;
- using System.Collections.Generic;
- namespace Program
- {
- public class Train
- {
- public static void Main()
- {
- // 1. Train
- //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 the sum of the people in the train.
- int n=int.Parse(Console.ReadLine());
- int[] arr = new int[n];
- int sum=0;
- for(int i = 0;i< arr.Length;i++)
- {
- arr[i]=int.Parse(Console.ReadLine());
- sum+=arr[i];
- }
- foreach(int index in arr)
- {
- Console.Write(index + " ");
- }
- Console.WriteLine(" ");
- Console.WriteLine(sum);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement