Pattern Problem – 5
You need to take an integer input and then draw the pattern according to it. Say for example if you enter 5 then, the pattern should be like this-
1 2 3 4 5 |
5 5 5 5 5 4 4 4 4 4 3 3 3 3 3 2 2 2 2 2 1 1 1 1 1 |
Input Format
You will take an integer input n from stdin.
Constraints
1 <= n <= 1000
Output Format
Your output should be the pattern according to the input which you had entered.
Sample TestCase 1
Input
5
Output:
1 2 3 4 5 |
5 5 5 5 5 4 4 4 4 4 3 3 3 3 3 2 2 2 2 2 1 1 1 1 1 |
Write a C program to print the following pattern
12345
5 5 5 5 54 4 4 4 43 3 3 3 32 2 2 2 21 1 1 1 1
1 2 3 4 5 |
5 5 5 5 5 4 4 4 4 4 3 3 3 3 3 2 2 2 2 2 1 1 1 1 1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
#include<stdio.h> int main() { int n=0,i=1; scanf("%d",&n); int num=n; while(n>0) { for(i=1;i<=num;i++) { printf("%d ",n); } printf("\n"); n--; } } |
Output:
1 2 3 4 5 |
5 5 5 5 5 4 4 4 4 4 3 3 3 3 3 2 2 2 2 2 1 1 1 1 1 |