Header Ads Widget

Friend's Relationship

Problem:-

Jack is your friend and Sophia is his girlfriend. But due to some unknown reason ( unknown for us, they know it) Sophia started hating to Jack. Now, Jack is in big trouble but he has a solution, He knows that if he will gift T patterns of a particular type ( For pattern observation see the sample test cases) then Sophia will start loving again to Jack. But Jack is depressed now and need your help to gift her that type patterns of '*' and '#' of N lines. So, it's your responsibility to save your friend's relationship.
Constraints :
1 ≤  T ≤ 100
1 ≤  N ≤ 30
Input :
First Line contains T i.e. number of test case.
Each of the next T lines contain an integer N.
Output:
For each test case print the pattern of N lines then after a blank line.
SAMPLE INPUT
 
3
9
2
5
SAMPLE OUTPUT
 
*################*
**##############**
***############***
****##########****
*****########*****
******######******
*******####*******
********##********
******************

*##*
****

*########*
**######**
***####***
****##****
**********
Time Limit:1.0 sec(s) for each input file.
Memory Limit:256 MB
Source Limit:1024 KB

solution:-

#include<stdio.h>
void main()
{
int n,i,j,n1,l,k;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
scanf("%d",&n1);
for(j=1;j<=n1;j++)
{
for(l=1;l<=j;l++)
printf("*");
for(l=1;l<=(n1-j)*2;l++)
printf("#");
for(l=1;l<=j;l++)
printf("*");
printf("\n");
}
printf("\n\n");
}
}

Post a Comment

0 Comments