Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public int[,] ReadMatrix(string path)
- {
- try
- {
- string[] mass = File.ReadAllLines(path);
- string[,] arr = new string[mass.Length, mass[0].Split(' ').Length];
- int[,] fd = new int[mass.Length, mass[0].Split(' ').Length];
- foreach (string line in mass)
- {
- foreach (char c in line)
- {
- for (int i = 0; i < mass.Length; i++)
- {
- for (int j = 0; j < mass[0].Split(' ').Length; j++)
- {
- fd[i, j] = Convert.ToInt32(c);
- }
- }
- }
- }
- return fd;
- }
- catch
- {
- throw new Exception("Некорректный формат");
- }
- }
- public int Readlnt(string path)
- {
- try
- {
- int cons = Convert.ToInt32(File.ReadAllText(path));
- return cons;
- }
- catch
- {
- throw new Exception("Некорректный формат");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement