Nov 15, 2009 at 1:44pm UTC
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;
}
Nov 15, 2009 at 1:54pm UTC
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 Nov 15, 2009 at 1:55pm UTC
Nov 15, 2009 at 3:30pm UTC
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