Code: Star Pattern
Code: Star Pattern
Send Feedback
Code: Star Pattern
N (Total no. of rows)
Pattern in N lines
0 <= N <= 50
3
*
***
*****
4
*
***
*****
*******
#include<iostream>using namespace std;
int main(){ int n; cin>>n; int row=1; while(n>=row){ int col=1; while(n-row>=col){ cout<<" "; col++; } int digit=1; while(row>=digit){ cout<<"*"; digit++; } int dec=row-1; while(dec>=1){ cout<<"*"; dec--; } cout<<endl; row++; } /* Read input as specified in the question. * Print output as specified in the question. */ }
Comments
Post a Comment