Number Pattern 2
Number Pattern 2
Send Feedback
Number Pattern 2
N (Total no. of rows)
Pattern in N lines
5
// #include<iostream>// using namespace std;
// int main(){// int n;// int row=1;// cin>>n; // while(n>=row){ // int space=1;// int count=row;// while(n-row>=space){// cout<<" ";// space++;// } // int j=1;// while(row>=j){ // cout<<count;// count++;// j++;// } // cout<<endl;// row++;// } // }
#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; count++; j++; } cout<<endl; row++; } return 0;}
Comments
Post a Comment