Advertisement
Denis1098

Untitled

Nov 14th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.30 KB | None | 0 0
  1.         public int[,] ReadMatrix(string path)
  2.         {
  3.             try
  4.             {
  5.                 string[] mass = File.ReadAllLines(path);
  6.                 string[,] arr = new string[mass.Length, mass[0].Split(' ').Length];
  7.                 int[,] fd = new int[mass.Length, mass[0].Split(' ').Length];
  8.                 foreach (string line in mass)
  9.                 {
  10.                     foreach (char c in line)
  11.                     {
  12.                         for (int i = 0; i < mass.Length; i++)
  13.                         {
  14.                             for (int j = 0; j < mass[0].Split(' ').Length; j++)
  15.                             {
  16.                                 fd[i, j] = Convert.ToInt32(c);
  17.                             }
  18.                         }
  19.                     }
  20.                 }
  21.                 return fd;
  22.             }
  23.             catch
  24.             {
  25.                 throw new Exception("Некорректный формат");
  26.             }
  27.         }
  28.         public int Readlnt(string path)
  29.         {
  30.             try
  31.             {
  32.                 int cons = Convert.ToInt32(File.ReadAllText(path));
  33.                 return cons;
  34.             }
  35.             catch
  36.             {
  37.                 throw new Exception("Некорректный формат");
  38.             }
  39.         }
  40.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement