C

Grid Of Grids Pattern

189
0

The program must accept the size of two grids(RxC and MxN) as the input. The program must print the MxN grid of RxC grids of asterisks as shown in the Example Input/Output section.

Boundary Condition(s):
2 <= R, C, M, N <= 20

Input Format:
The first line contains R and C separated by a space.
The second line contains M and N separated by a space.

Output Format:
The lines containing the MxN grid of RxC grids of asterisks as shown in the Example Input/Output section.

Example Input/Output 1:
Input:
2 3
4 4
Output:

***|***|***|***

***|***|***|***

—+—+—+—

***|***|***|***

***|***|***|***

—+—+—+—

***|***|***|***

***|***|***|***

—+—+—+—

***|***|***|***

***|***|***|***

#include<stdio.h>
#include<stdlib.h>

int main()
{
	int r,c,m,n;
	scanf("%d %d\n%d %d",&r,&c,&m,&n); 
	for (int w=0;w<m;w++)
	{
		for(int i=0;i<r;i++)
		{
			for(int k=0;k<n;k++)
			{
				for(int j=0;j<c;j++)
				{
					printf("*");
				}
				if(k!=n-1)
					printf("|");
			}
			printf("\n");
		}
		if(w!=m-1)
		{
			for(int j=0;j<n;j++)
			{
				for(int i=0;i<c;i++)
				{
					printf("-");
				}
				if(j!=n-1)
					printf("+");
			}
			printf("\n");
		}
	}
}
Hephzibai
WRITTEN BY

Hephzibai

Hephzibai is a driven third-year student at St. Joseph's Institute of Technology, specializing in Computer Science and Engineering. With a keen interest in data science and also in fullstack.
One of my greatest strengths lies in my programming skills, which I've honed through countless hours of practice and participation in coding challenges. Platforms like Skillrack, HackerRank, and others have been my playgrounds, where I've tackled a wide range of problems with creativity and determination.

Leave a Reply

Your email address will not be published. Required fields are marked *