In Python Decode the logic and print the pattern correspondent to given if n=3 then pattern will be 10203010011012**4050809***607
Answers
Answered by
0
import java.util.*;
class Main
{
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int num = in.nextInt();
int star = 0, space, lterm = 1, rterm = num * num+1, i , j;
for(i = num; i> 0; i--)
{
for(space = 1; space <=star; space++)
{
System.out.print("*");
}
star +=2;
for(j = 1; j <= i; j++)
{
System.out.print(lterm+"0");
lterm++;
}
for(j = 1; j<= i; j++)
{
System.out.print(rterm);
if(j < i)
{
System.out.print("0");
}
rterm++;
}
rterm = rterm - (i -1) * 2 -1;
System.out.println();
}
}
}
. Plz copy this url and get ur answer.....
class Main
{
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int num = in.nextInt();
int star = 0, space, lterm = 1, rterm = num * num+1, i , j;
for(i = num; i> 0; i--)
{
for(space = 1; space <=star; space++)
{
System.out.print("*");
}
star +=2;
for(j = 1; j <= i; j++)
{
System.out.print(lterm+"0");
lterm++;
}
for(j = 1; j<= i; j++)
{
System.out.print(rterm);
if(j < i)
{
System.out.print("0");
}
rterm++;
}
rterm = rterm - (i -1) * 2 -1;
System.out.println();
}
}
}
. Plz copy this url and get ur answer.....
Similar questions