Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace GitHub
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] arr1 = new int[] { 5,1,4,1,2 };
- int[] arr2 = new int[arr1.Length - 1];
- if (arr1.Length == 1)
- {
- Console.WriteLine(arr1[0]);
- return;
- }
- for (int first = 0; first < arr1.Length; first++)
- {
- Console.Write(arr1[first] + " ");
- for (int second = 0; second < arr2.Length - first; second++)
- {
- arr2[second] = arr1[second] + arr1[second + 1];
- }
- arr1 = arr2;
- }
- Console.WriteLine("\nSum= " + arr1[0]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment