Advertisement
vaakata

Matrices_1.06.2016

Jun 1st, 2016
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.29 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 Matrices_1._06._2016
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string[] input = Console.ReadLine().Split(' ').ToArray();
  14.  
  15.             int[] size = { Convert.ToInt32(input[1]), Convert.ToInt32(input[2]) };
  16.            
  17.             switch (input[0].ToUpper())
  18.             {
  19.                 case "A":
  20.                     PrintMatrixA(size);
  21.                     break;
  22.  
  23.                 case "B":
  24.                     PrintMatrixB(size);
  25.                     break;
  26.  
  27.                 case "C":
  28.                     PrintMatrixC(size);
  29.                     break;
  30.  
  31.                 case "D":
  32.                     PrintMatrixD(size);
  33.                     break;
  34.             }
  35.         }
  36.  
  37.         static void PrintMatrixA(int[] size)
  38.         {
  39.            
  40.             for (int rowA = 0; rowA < size[0]; rowA++)
  41.             {
  42.                 int rowFirstNumber = rowA + 1;
  43.                 for (int colA = 0; colA < size[1]; colA++)
  44.                 {                    
  45.                     Console.Write(rowFirstNumber + " ");
  46.                     rowFirstNumber += 4;
  47.                 }
  48.                 Console.WriteLine();
  49.             }
  50.         }
  51.  
  52.         static void PrintMatrixB(int[] size)
  53.         {
  54.             for (int rowB = 0; rowB < size[0]; rowB++)
  55.             {
  56.                 int rowFirstNumber = rowB + 1;
  57.                 for (int colB = 1; colB <= size[1]; colB++)
  58.                 {
  59.                     if (colB == 1)
  60.                     {
  61.                         Console.Write(rowFirstNumber + " ");
  62.                     }
  63.  
  64.                     if (colB % 2 == 0)
  65.                     {
  66.                         Console.Write(colB * size[0] - rowB + " ");
  67.                     }
  68.  
  69.                     if (colB % 2 != 0 && colB > 1)
  70.                     {
  71.                         Console.Write(colB * size[0] - (size[0] - 1) + rowB + " ");
  72.                     }
  73.                 }
  74.                 Console.WriteLine();
  75.             }
  76.         }
  77.  
  78.         static void PrintMatrixC(int[] size)
  79.         {
  80.            
  81.         }
  82.  
  83.         static void PrintMatrixD(int[] size)
  84.         {
  85.         }
  86.     }
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement