need help for array assignment. SUPER THANKS

I need to cout this 2d array first.:

Test1: TFTTT
Test2: TTTTT
Test3: TTFFT
Test4: FTFFF
Test5: FFFFF
Test6: TTTTT

then cout a 1d array to calculate the grade of this 6 tests.
The answer of the test is TTFFT, each question is worth 5 points, so in the 1d array, it will contains 6 numbers which are for the grade for each test. (they share the same answer)



i am doing the first part, cout the 2d array.

thats what i code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29

#include <iostream>
#include <iomanip>


using namespace std;

const int rows = 6;
const int cols = 5;
int main() {

char my_array2[6][5]={ {'T','F','T','T','T'},
                       {'T','T','T','T','T'},
                       {'T','T','F','F','T'},
                       {'F','T','F','F','F'},
                       {'F','F','F','F','F'},
                       {'T','T','F','T','F'}};
for(int r = 0; r < rows; r++){
for(int c = 0; c < cols; c++){
cout << my_array2[r][c] << endl;


}
}

 system("pause");
 return 0;
}



but it just cout a colum which shows all "TF"s.
What do i need to modify?

for the second part, calculate the grade, I am still woking on it.
Can anyone help me?

Super thanks
Last edited on
but it just cout a colum which shows all "TF"s.
What do i need to modify?


You end the line (endl) after every element. Don't do that.
so what do i need to put at the end of cout to seperate every 5 "TF"s, and make 6 rows?
if i take off the "endl", if prints a 1d array shows all "TF"s.

Thanks. =)
so what do i need to put at the end of cout to seperate every 5 "TF"s, and make 6 rows?


What's a line equivalent to? A row? And after outputting a row, might you want to end the line?

For each row (lines 18-24), output the row(lines 19-20) and end the line(line ?).
sorry, maybe i misunderstand.

I mean I want the output looks like this:


TFTTT
TTTTT
TTFFT
FTFFF
FFFFF
TTFTF


At what point in your code has a row finished being output? At that point, ouput a newline.

How would you do it on a piece of paper? How does that relate to your code?

Put on your critical thinking cap here.
the homework is required to use a 2d array to print out this

TFTTT
TTTTT
TTFFT
FTFFF
FFFFF
TTFTF


then use a 1d array to calculate the grade of each test.

each row is a test, each "T" or "F" is the answer of the question in the test.
each test has 5 question.
all of the tests use the same correct answer "TTFFT". I need to use this correct answer to compare each test and calculate the grade.

I didnt do it on papaer.

sorry, I think my words mislead you.
I am trying to modify, but i couldnt figure. =(
Topic archived. No new replies allowed.