Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace FixCode
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] arr = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
- if (arr.Length == 1)
- {
- Console.WriteLine(arr[0]);
- }
- else
- {
- int lastIndex = arr.Length - 1;
- while (lastIndex != 0)
- {
- for (int i = 0; i < lastIndex; i++)
- {
- arr[i] += arr[i + 1];
- }
- arr[lastIndex] = 0;
- lastIndex--;
- }
- Console.WriteLine(arr[0]);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement