T. Awesome Rectangle
Prolem link
Score: 1
CPU: 1s
Memory: 512MB
CPU: 1s
Memory: 512MB
Given
N you have to draw N rectangle. WhereLength of rectangle will be = 9Height of the rectangle will be = 4If N = 1*********
* *
* *
*********
If N=2********* *********
* * * *
* * * *
********* *********
If N=3********* ********* *********
* * * * * *
* * * * * *
********* ********* *********
There will be 1 space equal distance between two consecutive rectangle.
Input
First you will be given an positive integer
For each test case you will be given
Input
First you will be given an positive integer
T (1< T < 100), the number of test case.For each test case you will be given
N(1<= N <= 100) in different lines.
Output
For each test case you have to print
For each test case you have to print
N rectangle in each line as shown in the description. There will be 1 space equal distance between two consecutive rectangle in the same line.Sample
| Input | Output |
|---|---|
| 2 2 1 | ********* ********* * * * * * * * * ********* ********* ********* * * * * ********* |
Solution
#include<stdio.h> int main() { int i,j,n,k,l,t; scanf("%d",&t); for(l=1;l<=t;l++){ scanf("%d",&n); for(k=1;k<=4;k++){ for(i=1;i<=n;i++){ for(j=1;j<=9;j++) if(k!=1 && k!=4 && j!=1 && j!=9){ printf(" "); } else { printf("*"); } if(i<n) printf(" "); } printf("\n"); } } return 0; }
No comments:
Post a Comment