I’ve kickstarted to practice problem solving using C++ book by walter savitch and this is my first problem and in the first problem I’ve encountered difficulty.
#include <iostream>
using namespace std;
int main()
{
int size;
cout << "Enter the size of the pattern: ";
cin >> size;
for (int i = 0; i < size*2-1; i++)
{
for (int j = 0; j < size; j++)
{
if ((i==0&&j!=0||i==0&&j!=1)||(i==1&&j==1||i==1&&j==size-1)||(j==0&&i!=0||j==0&&i!=1||j==0&&i!=2*size-3||j==0&&i!=2*size-2)||(i==2*size-2&&j!=0||i==2*size-2&&j!=1)||(i==2*size-3&&j==1||i==2*size-3&&j==size-1))
cout << "X";
else
cout << " ";
}
cout << endl;
}
return 0;
}
My code produces a C but not like that way although my logic is alright imo.