I am working on a nxn magic square that I just cn't seem to figure out. Basically I have a data file that is .txt and has meta data.

3
Matrix One
5 7
45   38    5   56   18   34    4
87   56   23   41   75   87   97
45   97   86    7    6    8   85
67    6   79   65   41   37    4
 7   76   57   68    8   78    2
Matrix Two
6 8
45   38    5   56   18   34    4   30
87   56   23   41   75   87   97   49
45   97   86    7    6    8   85   77
67    6   79   65   41   37    4   53
 7   76   57   68    8   78    2   14
21   18   46   99   17    3   11   73
Matrix Three
6 6
45   38    5   56   18   34
87   56   23   41   75   87
45   97   86    7    6    8
67    6   79   65   41   37
 7   76   57   68    8   78
21   18   46   99   17    3

I have to read this into my program using an array, then create a report that will display these results in the console application. I have used StreamReader and Writer to create the text file and read in from the text file. But I'm stuck after that. I honestly just don't know what to do after that point. I'm not against using Linq, or classes to acheive the solution. The report will show each square above.

Once you have read the file into memory, you should be able to write each line out to the console. If you search for the Console.WriteLine function in your favourite search engine you will find plenty of examples.

Good luck!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.