static void Main(string[] args)
{
string str = @"F:\test.txt";
string[] n = File.ReadAllLines(str);
for (int i = 0; i < n.Length; ++i)
{
n[i] = n[i].Trim();
}
string[]m = System.Text.RegularExpressions.Regex.Split(n[0], @"\s{1,}");
string[,] A = new string[n.Length, m.Length];
for (int i = 0; i < n.Length; ++i)
{
for (int j = 0; j < m.Length; ++j)
{
string[] s = System.Text.RegularExpressions.Regex.Split(n[i], @"\s{1,}");
A[i, j] = s[j];
}
}
for(int i = 0; i < n.Length; ++i)
{
for (int j = 0; j < m.Length; ++j)
{
Console.Write(A[i, j] + ' ');
}
Console.WriteLine();
}
int[,]B=new int[n.Length, m.Length];
for (int i = 0; i < n.Length; ++i)
{
for (int j = 0; j < m.Length; ++j)
{
B[i, j] = int.Parse(A[i,j]);
}
}
for (int i = 0; i < n.Length; ++i)
{
for (int j = 0; j < m.Length; ++j)
{
Console.Write("{0} ",B[i,j]);
}
Console.WriteLine();
}
}
{
string str = @"F:\test.txt";
string[] n = File.ReadAllLines(str);
for (int i = 0; i < n.Length; ++i)
{
n[i] = n[i].Trim();
}
string[]m = System.Text.RegularExpressions.Regex.Split(n[0], @"\s{1,}");
string[,] A = new string[n.Length, m.Length];
for (int i = 0; i < n.Length; ++i)
{
for (int j = 0; j < m.Length; ++j)
{
string[] s = System.Text.RegularExpressions.Regex.Split(n[i], @"\s{1,}");
A[i, j] = s[j];
}
}
for(int i = 0; i < n.Length; ++i)
{
for (int j = 0; j < m.Length; ++j)
{
Console.Write(A[i, j] + ' ');
}
Console.WriteLine();
}
int[,]B=new int[n.Length, m.Length];
for (int i = 0; i < n.Length; ++i)
{
for (int j = 0; j < m.Length; ++j)
{
B[i, j] = int.Parse(A[i,j]);
}
}
for (int i = 0; i < n.Length; ++i)
{
for (int j = 0; j < m.Length; ++j)
{
Console.Write("{0} ",B[i,j]);
}
Console.WriteLine();
}
}