good afternoon gents, first semester cs student here. i'm having a world of confusion to create an X having the left formed with "+", the right side formed with "X" and the center with an "*". with an integer of 7, the output should look like:
+-----X
-+---X-
--+-X--
---^---
--+-X--
-+---X-
+-----X
my attempts thusfar outputs the x, but i cannot get the right symbols in the right place
#include<iostream>
using namespace std;
int main(){
int x;
cout<<"enter an odd positive integer ";
cin>>x;
while(x%2==0||x<0){
cout<<"enter an odd positive integer ";
cin>>x;
}
for(int i=0;i<x;i++){
for(int j=0;j<x;j++)
if(i==j&&(i+j<=x/2+1))
cout<<"+";
else if(i==j&&(i+j>x))
cout<<"X";
else if(i+j==x-1&&((i+j))
cout<<"X";
else if(i+j==x-1&&(i+j<x/2))
cout<<"+";
else if(i==x/2&&j==x/2)
cout<<"*";
else
cout<<" ";
cout<<endl;
}
return 0;
}
thank you gentlemen.