ARRAY []
#include <iostream>
using namespace std;
int main()
{
int x;
int y;
int array[8][8]; // Declares an array like a chessboard
for ( x = 0; x < 8; x++ ) {
for ( y = 0; y < 8; y++ )
array[x][y] = x * y; // Set each element to a value
}
cout<<"Array Indices:\n";
for ( x = 0; x < 8;x++ ) {
for ( y = 0; y < 8; y++ )
cout<<"["<<x<<"]["<<y<<"]="<< array[x][y] <<" ";
cout<<"\n";
}
cin.get();
}
>>:
x : 0 1 2 3 4 5 6 7 8 9
y : 0 1 2 3 4 5 6 7 8 9
x < 8 : T T T T T T T T T F
y < 8 : T T T T T T T T T F
x++ : 1 2 3 4 5 6 7 8 9
y++ : 1 2 3 4 5 6 7 8 9
PRINTED: 0 1 4 9 16 25 36 49 64 81
Tidak ada komentar:
Posting Komentar