Code : Inverted Number Pattern

 Code : Inverted Number Pattern

Send Feedback
Pattern for N = 4
4444
333
22
1
Input format :
Integer N (Total no. of rows)
Output format :
Pattern in N lines
Constraints :
0 <= N <= 50
Sample Input 1:
5
Sample Output 1:
55555 
4444
333
22
1
Sample Input 2:
6
Sample Output 2:
666666
55555 
4444
333
22
1

#include<iostream>
using namespace std;


int main(){
int row=1;
int n;
cin>>n;
while(n>=row){
int col=1;
while(n-row+1>=col){
cout<<n-row+1;
col++;
}
cout<<endl;
row++;
}

/* Read input as specified in the question.
* Print output as specified in the question.
*/
}



Comments

Popular posts from this blog

Code : All connected components

Coding Ninjas