asterisk

anyone can help me in doing this?

sample
side = 7

x.....x
.x...x.
..x.x..
...x...
..x.x..
.x...x.
x.....x


side = 10
x........x
.x......x.
..x....x..
...x..x...
....xx....
....xx....
...x..x...
..x....x..
.x......x.
x........x


thank you

this is my non working code


#include<iostream>
using namespace std;

int main()
{
int a;
cout<<"input side : ";
cin>>a;
for(int i = 0;i<a;i++)
{
for(int j = 0;j<a;j++)
if((i==j)||j==(a-1))
cout<<'*';
else
cout<<'.';
cout<<endl;
}
}
Last edited on
We can help you, but we won't write the code for you. Please post your non-working code and we can assist.
To get started, think about the patterns for each line.
Each line has N characters, and there are N lines... but each line also has 2 'x's. The two 'x's may be in the same spot, though (as in your example for N=7).
Topic archived. No new replies allowed.