I am writing C# program for a matrix.when I enter matrix inputs from console, each element is coming in the separate row.But, I want to read row elements in a single line.
This is my code
Console.WriteLine("Enter the matrix");
int n= Convert.ToInt32(Console.ReadLine());
int[ , ] matrix=new int[n,n];
for(int i=0; i<n; i++){
for(int j=0; j<n; j++){
matrix[i,j]=Convert.ToInt32(Console.ReadLine());
// Console.Write("\t");
}
}
present I am getting like
1
2
3
4
But, I want like
1 2
3 4
Help me.