horizontal display

Make a horizontal display of the arrays.
#include <iostream>

using namespace std;

const char ROWS = 13;
const char COLS = 4 ;
const char LEVELS = 3;

int main() {
char a[LEVELS][ROWS][COLS];

for(int level=0; level<LEVELS; level++) {
for(int row=0; row<ROWS; row++) {
for(int col=0; col<COLS; col++) {
if (col==0||col==3) {
a[level][row][col] = (row<5) ? 'B' : 'W';
} else {
a[level][row][col] = 'I';
}
}
}
}

for(int level=0; level<LEVELS; level++) {
cout << "--------------- LEVEL " << (level + 1) << " --------------------------" << endl;
cout << '+';
for(int col=0; col<COLS; col++) { cout << '\t' << (col+1); }
cout << endl;

for(int row=0; row<ROWS; row++) {
cout << (row + 1);
for(int col=0; col<COLS; col++) {
cout << '\t' << a[level][row][col];
}
cout << endl;
}
cout << endl;
}

system("pause");
return 0;
}
very nice.

Is this supposed to be a question or something?
How do I change the following code to display the arrays horizontally on the page.Apparently the display is vertical.

#include <iostream>

using namespace std;

const char ROWS = 13;
const char COLS = 4 ;
const char LEVELS = 3;

int main() {
char a[LEVELS][ROWS][COLS];

for(int level=0; level<LEVELS; level++) {
for(int row=0; row<ROWS; row++) {
for(int col=0; col<COLS; col++) {
if (col==0||col==3) {
a[level][row][col] = (row<5) ? 'B' : 'W';
} else {
a[level][row][col] = 'I';
}
}
}
}

for(int level=0; level<LEVELS; level++) {
cout << "--------------- LEVEL " << (level + 1) << " --------------------------" << endl;
cout << '+';
for(int col=0; col<COLS; col++) { cout << '\t' << (col+1); }
cout << endl;

for(int row=0; row<ROWS; row++) {
cout << (row + 1);
for(int col=0; col<COLS; col++) {
cout << '\t' << a[level][row][col];
}
cout << endl;
}
cout << endl;
}

system("pause");
return 0;
}
Topic archived. No new replies allowed.