Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static int[][] ReadAr(string path)
- {
- int[][] a = null;
- using (FileStream fstream = File.OpenRead(path))
- {
- // преобразуем строку в байты
- byte[] array = new byte[fstream.Length];
- // считываем данные
- fstream.Read(array, 0, array.Length);
- // декодируем байты в строку
- string textFromFile = System.Text.Encoding.Default.GetString(array);
- string[] textArray = textFromFile.Split('\n');
- string[][] textArray1 = new string[textArray.Length][];
- for (int i = 0; i < textArray.Length; i++)
- {
- textArray1[i] = textArray[i].Split(' ');
- }
- a = new int[textArray1.Length][];
- for (int i = 0; i < textArray1.Length; i++)
- {
- a[i] = new int[textArray1[i].Length];
- for (int j = 0; j < textArray1[i].Length; j++)
- {
- a[i][j] = Int32.Parse(textArray1[i][j]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment