Skip to content

Instantly share code, notes, and snippets.

@Zyro9922
Created January 26, 2018 11:13
Show Gist options
  • Save Zyro9922/b11f81fa4b031d9f9ff901a1849dd9ad to your computer and use it in GitHub Desktop.
Save Zyro9922/b11f81fa4b031d9f9ff901a1849dd9ad to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
int main()
{
int n,r,c;
cin>>n;
//first line
for(int i = 0 ; i < n ; i++)
{
if(i==0)
cout<<'*';
else if(i>0&&i<(n/2))
cout<<" ";
else
cout<<'*';
}
for(r = 1 ; r < (n/2) ; r++)
{
cout<<endl;
for(c = 0 ; c < n ; c++)
{
if(c==0||c==(n/2))
cout<<'*';
else
cout<<" ";
}
}
cout<<endl;
for(int i = 0 ; i < n ; i++)
cout<<'*';
//below
r++;//r=3
for( ; r < (n-1) ; r++)
{
cout<<endl;
for(c = n-1 ; c >= 0 ; c--) //n-1 = 4
{
if(c==0||c==(n/2))
cout<<'*';
else
cout<<" ";
}
}
cout<<endl;
for(int i = n-1 ; i >= 0 ; i--)
{
if(i==0)
cout<<'*';
else if(i>0&&i<(n/2))
cout<<" ";
else
cout<<'*';
}
cout<<endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment