PATT12: Editorial
Problem-code: PATT12
Contest-Code: CSMH2021
Author: M RAHUL
Editorialist: M RAHUL
DIFFICULTY: SIMPLE
PREREQUISITES:
Basic observations, for loops
PROBLEM:
Your task is very simple. Just print the pattern for corresponding N value by observing sample test cases.
EXPLANATION:
Here you’ve to print the pattern of given ‘n’ value. The pattern is to print both the diagonals as empty space and the rest as ‘’.
Here if i==j or i+j==n-1 then print ’ ’ else print '’.
SOLUTION:
#include <stdio.h>
int main() {
int n,m,i,j;
scanf("%d",&n);
m=2n-1;
for(i=1;i<=m;i++)
{
for(j=1;j<=m;j++)
{
if(i==j || j==(m-i+1))
{
printf(" “);
}
else
{
printf(”");
}
}
printf("\n");
}
return 0;
}
Feel free to Share your approach, if you want to. (even if its same
) . Suggestions are welcomed as always had been. 