Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.IO;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- string path = @"C:\file.txt";
- string[] lines = File.ReadAllLines(path);
- double[,] mat = new double[lines.Length, lines.Length + 1];
- for (int i = 0; i < lines.Length; i++)
- {
- var strvalues = lines[i].Split('\t');
- for (int j = 0; j < strvalues.Length; j++)
- {
- var val = 0.0;
- var ok = double.TryParse(strvalues[j], out val);
- if (ok)
- {
- mat[i, j] = val;
- }
- else
- {
- Console.WriteLine("Error while reading element [{0},{1}]\n", i, j);
- }
- }
- }
- for (int i = 0; i < mat.GetLength(0); i++)
- {
- for (int j = 0; j < mat.GetLength(1); j++)
- {
- Console.Write("{0} ", mat[i,j]);
- }
- Console.WriteLine();
- }
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement