Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2020
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.38 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ElijahGay
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             ArrayMovements.createRandomArray(20);
  14.            
  15.             ArrayMovements.revertArray(ArrayMovements.createRandomArray(20));
  16.  
  17.             Console.ReadKey();
  18.         }
  19.     }
  20.  
  21.     class ArrayMovements
  22.     {
  23.         public static string createRandomArray(int len)
  24.         {
  25.             Random rnd = new Random();
  26.             int[] arr = new int[len];
  27.             string res = "";
  28.  
  29.             for(int i = 0; i < len; i++)
  30.             {
  31.                 arr[i] = rnd.Next(1000);
  32.                 Console.WriteLine("------------  " + arr[i]);
  33.                 res += arr[i] + " ";
  34.             }
  35.  
  36.             return res;
  37.         }
  38.  
  39.         public static void revertArray(string strArr)
  40.         {
  41.             int[] arr = new int[20];
  42.             string ns = strArr;
  43.  
  44.             ns.Split().Select(e => Convert.ToInt32(e));
  45.  
  46.             for (int i = 0; i < 20; i++)
  47.             {
  48.                 arr[i] = ns[i];
  49.             }
  50.            
  51.  
  52.             for(int i = 0; i < 20; i++)
  53.             {
  54.                 arr[i] = strArr[20 - i];
  55.                 Console.WriteLine(">>>>>>>>>>  " + arr[i]);
  56.             }
  57.  
  58.        
  59.         }
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement