I'm attempting to create a square shape from X's and O's (the border being X's and the interior being O's), and I'm trying to avoid the last bit of code with my for loop printing on the same line. Any help would be greatly appreciated!
#include <iostream>
using namespace std;
int main() {
int x = 0;
cout << "Please enter an integer for the dimension that will represent the "
"rows and columns: "
<< endl;
cin >> x;
cout << endl;
for (int i = 0; i <= x; i++) {
for (int j = x; j > i; j--)
cout << "X";
cout << endl;
}
for (int i = 0; i < x; i++) {
for (int j = 0; j < i; j++) {
cout << " ";
}
for (int k = x; k >= i + 1; k--) {
cout << "X";
}
cout << endl;
}
cout << endl;
for (int m = 0; m < x; m++) {
cout << "X";
}
for (int m = 0; m < x - 2; m++) {
cout << "X";
for (int n = 0; n < x - 2; n++) {
cout << "O";
}
}
for (int m = 0; m < x; m++) {
cout << "X";
}
cout << endl;
return 0;
}