Print Something Different:
void main()
{
int sq=0;
cout<<"input the value for the square(HAS TO BE AN ODD NUMBER)-";
cin>>sq;
for (int pcol=1; pcol<=sq;pcol++)
{
if(pcol==1)||(pcol==sq)
for(int exc=1;exc<=sq;exc++)
cout<<"1";
else
{
for(int prow=1;prow<=sq;prow++)
{
if (prow==1)||(prow==sq)
cout<<"1";
else
if((pcol==2)||(pcol>sq-2))
cout<<"0";
else
if((prow==(sq/ 2)+1)&&(pcol==(sq/2)+1)
cout<<"0";
else
cout<<"1";
}
}
cout<<endl;
}
getch();
}
The above will create the following design for 9
111111111
100000001
101111101
101111101
101101101
101111101
101111101
100000001
111111111
void main()
{
int sq=0;
cout<<"input the value for the square(HAS TO BE AN ODD NUMBER)-";
cin>>sq;
for (int pcol=1; pcol<=sq;pcol++)
{
if(pcol==1)||(pcol==sq)
for(int exc=1;exc<=sq;exc++)
cout<<"1";
else
{
for(int prow=1;prow<=sq;prow++)
{
if (prow==1)||(prow==sq)
cout<<"1";
else
if((pcol==2)||(pcol>sq-2))
cout<<"0";
else
if((prow==(sq/
cout<<"0";
else
cout<<"1";
}
}
cout<<endl;
}
getch();
}
The above will create the following design for 9
111111111
100000001
101111101
101111101
101101101
101111101
101111101
100000001
111111111
No comments:
Post a Comment