VitalyD

Untitled

May 11th, 2018
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.58 KB | None | 0 0
  1. using System;
  2. using System.Threading;
  3.  
  4. namespace Delegates
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             string[][] data =
  11.             {
  12.                 new string[]{"C1R1", "C1R2", "C1R3"},
  13.                 new string[]{"C2R1", "C2R2", "C2R3", "C2R4" },
  14.                 new string[]{"C3R1", "C232"},
  15.             };
  16.  
  17.  
  18.             DrawTable(data);
  19.  
  20.             /*
  21.                 Column 1 | Column 2 | Column 3
  22.                 C1R1     | C2R1     | C3R1
  23.                 C1R2     | C2R2     | C3R2
  24.                 C1R3     | C2R3     | Empty
  25.                 Empty    | C2R4     | Empty                
  26.              */
  27.  
  28.             //Console.WriteLine(GetCell(data, 0, 0)); //C1R1
  29.             //Console.WriteLine(GetCell(data, 1, 2)); //C3R2
  30.             //Console.WriteLine(GetCell(data, 2, 2)); //Empty
  31.         }
  32.  
  33.         static string GetCell(string[][] data, int column, int raw)
  34.         {
  35.             string ansv;
  36.             if (column > data.Length-1 || raw > data[column].Length-1)
  37.             {
  38.                 ansv = "Ошибка";
  39.             } else ansv = ansv = data[column][raw];
  40.  
  41.             return ansv;
  42.         }
  43.  
  44.  
  45.         static void DrawTable(string[][] data)
  46.         {
  47.             for (var i = 0; i < data.Length; i++)
  48.             {
  49.                 for (var j = 0; j < data[i].Length; j++)
  50.                 {
  51.                     Console.Write(data[i][j] + "     ");
  52.                     Console.WriteLine();
  53.                 }
  54.                 Console.WriteLine();
  55.             }
  56.            
  57.         }
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment