Created
July 22, 2018 12:24
-
-
Save Zyro9922/4a055f12540426db39553c5be669ba2c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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