Advertisement
AmidamaruZXC

task4

Oct 16th, 2020
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.11 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 Task4
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string input = Console.In.ReadToEnd();
  14.             string[] strings = input.Split('\n');
  15.             char[] MyChar = { '\r', ']', '[' };
  16.             int n = strings.Length - 3;
  17.             int m = strings[1].Split(',').Length - 1;
  18.             int[,] matrix = new int[n, m];
  19.             for (int i = 1; i < strings.Length - 2; ++i)
  20.             {
  21.                 string[] str = strings[i].Split(',');
  22.                 str[0] = str[0].TrimStart(MyChar);
  23.                 str[str.Length - 2] = str[str.Length - 2].TrimEnd(MyChar);
  24.                 for (int j = 0; j < str.Length - 1; ++j)
  25.                     matrix[i - 1, j] = int.Parse(str[j]);
  26.             }
  27.             for (int i = 0; i < n; i++)
  28.             {
  29.                 for (int j = 0; j < m; j++)
  30.                     Console.Write($"{matrix[i, j]} ");
  31.                 Console.WriteLine();
  32.             }
  33.         }
  34.     }
  35. }
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement