Welcome

>>>Welcome to my "CODE BAZAR"
Code marshal
URI online judge
Others
Code marshal
URI online judge
Others
Code marshal
URI online judge
Others

Update ✔✔✔ Upcoming programming book (.pdf) "Programming Contest (data structures and algorithms) by Md. Mahbub Hasan & "Graph Algorithms" by Safayat Asraf "****** Date: 20 March, 2019****Hazrat Ali****

Monday 31 October 2016

T. Awesome Rectangle

Prolem link
Score: 1

CPU: 1s
Memory: 512MB

Given N you have to draw N rectangle. Where
Length of rectangle will be = 9
Height of the rectangle will be = 4

If 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 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 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

InputOutput
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