Oct 1, 2008 at 1:29am UTC
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 Oct 7, 2008 at 1:16pm UTC
Oct 1, 2008 at 11:59am UTC
We can help you, but we won't write the code for you. Please post your non-working code and we can assist.
Oct 1, 2008 at 7:14pm UTC
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).