You are on page 1of 4

// 1 //9 spaces

// 234 //7 spaces

// 56789 //5 spaces

// 10 11 12 13 14 15 16 //0 spaces

//1 //9 spaces

//2 3 4 //7 spaces

//5 6 7 8 9 //5 spaces

//10 11 12 13 14 15 16 //0 spaces

import java.util.*;

class dssd

static void main(String args[])

int i,j,k,l,a;

Scanner sc=new Scanner(System.in);

System.out.println("ENTER THE NO OF ROWS WANTED ");

int n=sc.nextInt();

int s=(n/2)*(2+((n-1)*2));

for(i=1,j=1,a=(n-1)*(n-1);i<=s;j+=2,i++,a-=2)

for(k=1;k<=j;k++)

{
if(k==1)

for(l=a;l>0;l--)

System.out.print(" ");

System.out.print(i+" ");

if(k<j)

i++;

System.out.println();

--------------------------------------------------------------------------------------------------------------------------

/*

101

10101

1010101

10101

101

*/
import java.util.*;

class ds

static void main(String args[])

int i,j,k,c,a=1;

System.out.println("ENTER THE LIMIT OF ROWS ( PREFERABLY ODD ) ");

Scanner sc=new Scanner(System.in);

int n=sc.nextInt();

int s=(1+((n-1)*2));

for(i=1;i<=n;i+=2,a++)

for(c=a;c<(n+1)/2;c++)

System.out.print(" ");

for(j=1,k=1;k<=i&&j<=s;j++,k++)

System.out.print(j%2);

System.out.println();

for(i=((n*2)-(1+2))/2,a=1;i>0;i-=2,a++)

for(c=1;c<=a;c++)

System.out.print(" ");
for(j=1,k=1;k<=i&&j<=s;j++,k++)

System.out.print(j%2);

System.out.println();

You might also like