Advertisement
radidim

array (C# Shell App Paste)

Jan 27th, 2021
1,448
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.64 KB | None | 0 0
  1. //Disclaimer: The creator of 'C# Shell (C# Offline Compiler)' is in no way responsible for the code posted by any user.
  2. using System;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Collections.Generic;
  6.  
  7. namespace CSharp_Shell
  8. {
  9.  
  10.     public class Program
  11.     {
  12.         public static void Main()
  13.         {
  14.             var array = new int[] { 5, 0, 4, 1, 2 };
  15.  
  16.             for (int i = 0; i < array.Length; i++)
  17.             //while (array.Length > 1)
  18.             {
  19.                 var newarr = new int[array.Length - 1];
  20.  
  21.                 for (int j = 0; j < newarr.Length; j++)
  22.                 {
  23.                     newarr[j] = array[j] + array[j + 1];
  24.                 }
  25.  
  26.                 array = newarr;
  27.             }
  28.             foreach (var item in array)
  29.             {
  30.                 Console.Write(item);
  31.             }
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement