Pattern Printing - 005
Given an integer N as the input, the program must print 2N lines pattern output as described in the Example Input/Output given below.
Input Format:
The first line contains N.
The first line contains N.
Output Format:
2N lines of the pattern.
2N lines of the pattern.
Boundary Conditions:
2 <= N <= 100
2 <= N <= 100
Example Input/Output 1:
Input:
4
Input:
4
Output:
1
22
333
4444
4444
333
22
1
1
22
333
4444
4444
333
22
1
Example Input/Output 2:
Input:
10
Input:
10
Output:
1
22
333
4444
55555
666666
7777777
88888888
999999999
10101010101010101010
10101010101010101010
999999999
88888888
7777777
666666
55555
4444
333
22
1
1
22
333
4444
55555
666666
7777777
88888888
999999999
10101010101010101010
10101010101010101010
999999999
88888888
7777777
666666
55555
4444
333
22
1
C program:
#include<stdio.h>
#include <stdlib.h>
int main()
{
int n,i,j;
scanf("%d",&n);
for(i=1;i<=2*n;i++){
if(i<=n)
for(j=0;j<i;j++)
printf("%d",i);
else
for(j=0;j<2*n-i+1;j++)
printf("%d",2*n-i+1);
printf("\n");
}
}
solution is nice...
ReplyDeleteCode not passing 😐
ReplyDelete