Advertisement
Guest User

Untitled

a guest
Dec 13th, 2015
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.11 KB | None | 0 0
  1. public static int[,] OdczytajMacierz(string nazwa)
  2.         {
  3.             StreamReader sr = null;
  4.             int licznik = 0;
  5.             sr = new StreamReader(nazwa);
  6.             while (!sr.EndOfStream)
  7.             {
  8.                 sr.ReadLine();
  9.                 licznik++;
  10.             }
  11.             sr.Close();
  12.             sr = new StreamReader(nazwa);
  13.             string pomocniczy = sr.ReadLine();
  14.             sr.Close();
  15.             string[] tablicapomocnicza = pomocniczy.Split(' ');
  16.             int[,] tablica = new int[licznik, tablicapomocnicza.Length];
  17.             sr = new StreamReader(nazwa);
  18.             int k = 0;
  19.             for (int i = 0; i < tablica.GetLength(0); i++)
  20.             {
  21.                 k = 0;
  22.                 pomocniczy = sr.ReadLine();
  23.                 tablicapomocnicza = pomocniczy.Split(' ');
  24.                 for (int j = 0; j < tablica.GetLength(1); j++)
  25.                 {
  26.                     tablica[i, j] = Convert.ToInt32(tablicapomocnicza[k]);
  27.                     k++;
  28.                    
  29.                 }
  30.             }
  31.             return tablica;
  32.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement