#include<iomanip> using namespace std; int main() { int num; cout<<"enter a number"<<endl; cin>>num; int i=0; for(int r=1;r<=num+1;r++){ for(int c=1;c<=r;c++){ cout<<'*';} int b = 2*num-2*r+2; for(int s=1;s<=b;s++){ cout<<' '; i=i+1; } for(int c=1;c<=r;c++){ cout<<'*'; } cout<<endl; } for(int r=1;r<=num;r++){ for(int c=1;c<=num+1-r;c++){ cout<<'*';} for(int s=0;s<=2*r-1;s++){ cout<<' '; } for(int c=1;c<=num+1-r;c++){ cout<<'*'; } cout<<endl; } return 0; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter