0

C++ / can anybody Help me?

(In the C++ Course of Practical Mission: Cinema) i cant find the solution.... I should do all [cols] of the Arrays Change from 0 to 1. I try all but i get Always the information after i run the Code that i cant Safe integer in float Arrays... But when i Change the int's of the for Loops its gone Not better...😭 Please Help Guys.. what do i wrong? #include <iostream> using namespace std; int main() { int rows = 6; int cols = 6; float matrix[rows][cols] = { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, }; for (int i = 0; i<=5; i++) { for (int j = 0; j<=5; j++) { matrix[j] = 1;} } for (int i = 0; i<=5; i++) { for (int j = 0; j<=5; j++) { cout << matrix[j] << endl;} } }

4th Feb 2024, 12:21 AM
Niklas Besicke
Niklas Besicke - avatar
1 Resposta
+ 5
You have defined the matrix as a two-dimensional array, respectively, and the input of values must be performed as for a two-dimensional array: matrix[i][j] = 1;
4th Feb 2024, 12:46 AM
Solo
Solo - avatar