ZeroSeventty

Array populate and populate 2th array with the first but reversed [C#]

Oct 23rd, 2020 (edited)
1,107
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7.  
  8. namespace program
  9. {
  10.     class populateReversed
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             int[] arr = new int[10];
  15.             for(int i = 0; i<arr.Length; i++){
  16.                 arr[i] = i;
  17.             }
  18.                 reverseArr(arr);
  19.         }
  20.         public static void reverseArr(int[] arr){
  21.             int counter = arr.Length;
  22.             int[] reversedArr = new int[arr.Length];
  23.             for(int i = 0; i<reversedArr.Length; i++){
  24.                 reversedArr[i] = counter--;
  25.             }
  26.             foreach(int value in reversedArr){
  27.                 Console.WriteLine(value + "\n");
  28.             }
  29.         }
  30.     }
  31. }
  32.  
RAW Paste Data