MuffinMonster

Class Task 47#

Feb 12th, 2014
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.44 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApplication1
  7. {
  8.     class Program
  9.     {
  10.         static void Insert(int[,] Arr)
  11.         {
  12.             Random r = new Random();
  13.             for (int i = 1; i < Arr.GetLength(0); i++)
  14.             {
  15.                 for (int j = 0; j < Arr.GetLength(1); j++)
  16.                 {
  17.                     Arr[0, j] = j + 11;
  18.                     Arr[i, j] = r.Next(10000, 100000);
  19.                 }
  20.             }
  21.         }
  22.         static void Draw(int[,] Arr)
  23.         {
  24.             for (int i = 0; i < Arr.GetLength(0); i++)
  25.             {
  26.                 for (int j = 0; j < Arr.GetLength(1); j++)
  27.                 {
  28.                     Console.Write(Arr[i, j] + " | ");
  29.                 }
  30.                 Console.WriteLine();
  31.             }
  32.         }
  33.         static int FindCode(int[,] Arr, int locker)
  34.         {
  35.             int code = Arr[1, locker - 11];
  36.             return code;
  37.         }
  38.         static void Main(string[] args)
  39.         {
  40.             int[,] Arr = new int[2, 89];
  41.             Insert(Arr);
  42.             Draw(Arr);
  43.             Console.WriteLine();
  44.             Console.WriteLine("Enter the number of your locker: ");
  45.             int input = int.Parse(Console.ReadLine());
  46.             int code = FindCode(Arr, input);
  47.             Console.WriteLine("Your code is : " + code);
  48.             Console.ReadKey();
  49.         }
  50.     }
  51. }
Add Comment
Please, Sign In to add comment