S
Steve
Hello,
I need help with formatting an output of an array.
I have a two dimensional array that looks something like this:
[1] x x x x
[2] y y y y
[3] b b b b
....and so on...I use [#] to just represent the row number whereas x, y, b
are some values in the array. I have no problem displaying the array on the
screen in the form above by using the following code:
for (down = 0; down < numStudents; down++)
{
cout << arrayStudents[down] <<"\t";
for (accross = 0; accross < numQuizzes; accross++)
{
cout << "\t" << arrayQuizzes[down][accross] <<"\t";
}
cout << endl;
}
But what I need is to display the array in the following form:
[1] [2] [3]
x y b
x y b
x y b
I tried modifying the code above so that the cout would display:
cout << "\t" << arrayQuizzes[accross][down] <<"\t";
But this only works if numStudents and numQuizzes are equal to each other.
If there are more students than there are quizzes then the array doesnt
display properly any more..
How else can I format the output so it looks like this:
[1] [2] [3]
x y b
x y b
x y b
but still works if the number of rows and columns are not equal.
Thanks
I need help with formatting an output of an array.
I have a two dimensional array that looks something like this:
[1] x x x x
[2] y y y y
[3] b b b b
....and so on...I use [#] to just represent the row number whereas x, y, b
are some values in the array. I have no problem displaying the array on the
screen in the form above by using the following code:
for (down = 0; down < numStudents; down++)
{
cout << arrayStudents[down] <<"\t";
for (accross = 0; accross < numQuizzes; accross++)
{
cout << "\t" << arrayQuizzes[down][accross] <<"\t";
}
cout << endl;
}
But what I need is to display the array in the following form:
[1] [2] [3]
x y b
x y b
x y b
I tried modifying the code above so that the cout would display:
cout << "\t" << arrayQuizzes[accross][down] <<"\t";
But this only works if numStudents and numQuizzes are equal to each other.
If there are more students than there are quizzes then the array doesnt
display properly any more..
How else can I format the output so it looks like this:
[1] [2] [3]
x y b
x y b
x y b
but still works if the number of rows and columns are not equal.
Thanks