Venciity

[Jumpstart C#] Multidimensional-Arrays 05

Mar 5th, 2014
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.03 KB | None | 0 0
  1. /*Матрицата A(M,N) пре­хвър­лена в масива B(K) по стъл­бо­ве.
  2.  *При зададени i и j, да се оп­ре­дели индекса на елемента Aij в масива В.  */
  3.  
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9.  
  10. namespace _02_NegaitveElements
  11. {
  12.     class Program
  13.     {
  14.         static void Main(string[] args)
  15.         {
  16.             //Console.WriteLine("Enter i= ");
  17.             //int i = Int32.Parse(Console.ReadLine());
  18.  
  19.             int[,] a = new int[3, 5]
  20.             {
  21.                 {0, 3, 6, 9, 12},
  22.                 {1, 4, 7, 10, 13},
  23.                 {2, 5, 8, 11, 14}
  24.             };
  25.  
  26.             int rows = a.GetLength(0);
  27.             int cols = a.GetLength(1);
  28.  
  29.             int[] b = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 };
  30.  
  31.             int i = 1;  // РЕД 1
  32.             int j = 4;  // КОЛОНА 4
  33.  
  34.             int k = j * rows + i;
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment