Start Pattern
Start Pattern
Send Feedback
Start Pattern
N (Total no. of rows)
Pattern in N lines
0 <= N <= 50
3
*
***
*****
4
*
***
*****
*******
/*#include<iostream>using namespace std;
int main(){ int n; int row=1; cin>>n; while(n>=row){ int space=1; while(n-row>=space){ cout<<" "; space++; } int star=1; while(row>=star){ cout<<"*"; star++; } int dec=row-1; while(dec>=1){ cout<<"*"; dec--; } row++; cout<<endl; }
}*/
#include <iostream>using namespace std;
int main(int argc, char** argv) { int n; cin>>n; int row=1; while(n>=row){ int count=row; int space=1; while(n-row>=space){ cout<<" "; space++; } int j=1; while(row>=j){ cout<<"*"; count++; j++; } int decreasings=row-1; while(decreasings>=1){ cout<<"*"; decreasings--; } cout<<endl; row++; } return 0;}
Comments
Post a Comment