#include<iostream>
usingnamespace std;
int main()
{
char space(' ');
int a,b;
b = 0;
cin >> a;
for (int i = 0; i < a; i++)
cout << "x" << " ";
for (int h = 0; h < a; h++)
{
cout << endl << "x";
for (int g = 0; g < a; g++)
cout << space << "x";
}
for (int j = 0; j < a; j++)
cout << "x" << " ";
return 0;
}
You have one to many for loops. The loop at line 20 and 21 is not needed. And the lines 11 - 19 need to b nested for loops. The for loop at lines 17 and 18 are not needed either.
You define an int 'b', but never use it and you should initialize variable 'a' int a{ 0 }; or whichever way you like. It is just a good practice.
In line 16 remove the endl and put a space after the 'x' which makes line 7 unneeded.