Input a stream of integers (each from 0…999 range), that is elements of N×N matrix, ordered by rows. Detect this N and output the matrix (note "%3d" format is used). Also note the task can not be reasonably solved when input is manual. Assume input is always redirected from file like task < example_file.

260   301   565   56
895 361 993 627 180 423 198 117 370 810
390

885       314 708
632 678    97   273 811
976  44

You need to scan stream twice: first to detect N and allocate memory, an second to input an array. Use fseek(stdin, 0, SEEK_SET) to rewind stream redirected from file. And no, there a no two-dimensional arrays here.

If you use sqrt function, you need to link your program with libm mathematical library as this: cc task.c -lm -o task.

260 301 565  56 895
361 993 627 180 423
198 117 370 810 390
885 314 708 632 678
 97 273 811 976  44


CategoryHomework

HSE/ProgrammingOS/Homework_MatrixDisplay (последним исправлял пользователь FrBrGeorge 2020-03-05 13:30:48)