| bestnone (9) | |
|
i am trying to get all the array arrange in 1 2 3 and - with 128 4 5 6 7 8 9 #include <iostream> using namespace std; int main() { int a; int x; int y; int array[3][3]; array[0][0] = 1; array[0][1] = 2; array[0][2] = 3; array[1][0] = 4; array[1][1] = 5; array[1][2] = 6; array[2][0] = 7; array[2][1] = 8; array[2][2] = 9; for ( x = 0; x < 3; x++ ) { for ( y = 0; y < 3; y++ ) a = array[x][y] - 128; cout << a << endl; } return 0; } | |
|
|
|
| Bazzy (6275) | |||
You need some more braces:
Please use [code][/code] tags | |||
|
|
|||
| AleaIactaEst (23) | |
|
You want your function to print 9 lines and not 1? In this case you'll have to add the brackets of the second for-loop, because the second loop affects a = array[x][y] - 128; only and not cout << a << endl;by the way, use code-tags next time please Edit: too slow... | |
|
Last edited on
|
|
| bestnone (9) | |
|
it is still the same when i added the braces it is just one line i want it to be 1 2 3 4 5 6 7 8 9 like matrix form | |
|
|
|
| AleaIactaEst (23) | |||
|
the output can not be the same if you added the brackets at the correct position.. well, maybe this code will work for you:
| |||
|
|
|||
| bestnone (9) | |
| thx man it works | |
|
|
|