Skip to content

Instantly share code, notes, and snippets.

@Zyro9922
Created July 22, 2018 12:24
Show Gist options
  • Save Zyro9922/4a055f12540426db39553c5be669ba2c to your computer and use it in GitHub Desktop.
Save Zyro9922/4a055f12540426db39553c5be669ba2c to your computer and use it in GitHub Desktop.
#include<iostream>
using namespace std;
int main()
{
int n;
cin>>n;
//TOP
for(int i = 0 ; i < n ; i++)
cout<<"* ";
cout<<endl;
//FIRST HALF
int gap = 1;
for(int i = 1 ; i <= n - 1 ; i++)
{
int j = 0;
for( ; j < gap ; j++)
cout<<" ";
j = 0;
for( ; j < n - i ; j++)
cout<<"* ";
cout<<endl;
gap++;
}
//SECOND HALF
gap = n - 2; // 3
for(int i = 1 ; i <= n - 2 ; i++)
{
int j = 0;
for( ; j < gap ; j++)
cout<<" ";
j = 0;
for( ; j < i+1 ; j++)
cout<<"* ";
gap--;
cout<<endl;
}
//BOTTOM
for(int i = 0 ; i < n ; i++)
cout<<"* ";
cout<<endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment