I need to take as an input matrix N*M from stdin & print it as a
matrix shape, something like:
First, pick one group and stick to it. Don't multi-post your
message to many different groups. If you *must* post to multiple
groups, then cross-post, like I did in this response (a response
written in response to your question in comp.lang.c, BTW).
Secondly, no matter what language you're using, you need to
know *what* you're doing before worrying about the *how*. What
kind of input is the user going to be typing? Is he going to
enter
1 2 3 4 5 6 7 8 9
and you're by magic going to print
1 2 3
4 5 6
7 8 9
or is the user going to have to tell the program how many dimensions
the matrix has, and what size it is, like this?
4 2
1 2 3 4 5 6 7 8
and then you would print a 4-by-2 matrix
1 2 3 4
5 6 7 8
Maybe the user is going to enter his matrix himself, and use some
special code to indicate that he's done entering rows, like this:
1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
done
In this last case, would you output
1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
or would your user rather see
1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
In the latter case, should the entries by justified toward the right,
the left, or centered: e.g.,
1 2 3
42 567 8
17 42 725
Should the columns all be equally wide, e.g.
1 2 65535
3 4 5
or should they have variable width, e.g.
1 2 65535
3 4 5
If the latter, then would it be acceptable to overlap
columns on particularly odd inputs, e.g.
1 2 1234567890 3 4
2 456 89 10112 7
If not, then how many spaces between columns? Are hard
tabs okay? (Hint: no.
Answer these questions for
yourself, and *then* think about what algorithms you'll
need to implement.
Once you know not only *what* you're doing, but also
*how* you'll do it (i.e., the algorithms involved), then
you'll finally be ready to start asking questions that
might be topical on comp.lang.c and alt.comp.lang.learn.c-c++.
We deal with the C *language* here, not algorithms; for
algorithm help, try comp.programming.
-Arthur