Advertisement
Teodor92

SimpleMatrix

Nov 13th, 2012
358
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.70 KB | None | 0 0
  1. using System;
  2.  
  3. class SimpleMatrix
  4. {
  5.     static void Main()
  6.     {
  7.         int size = int.Parse(Console.ReadLine());
  8.         int[,] matrix = new int[size, size];
  9.         for (int row = 0; row < matrix.GetLength(0); row++)
  10.         {
  11.             int start = row + 1;
  12.             for (int col = 0; col < matrix.GetLength(1); col++)
  13.             {
  14.                 matrix[row, col] = start;
  15.                 start++;
  16.             }
  17.         }
  18.         for (int i = 0; i < matrix.GetLength(0); i++)
  19.         {
  20.             for (int j = 0; j < matrix.GetLength(1); j++)
  21.             {
  22.                 Console.Write("{0,4}", matrix[i, j]);
  23.             }
  24.             Console.WriteLine();
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement