+ 1

How to print this pattern

1234554321 1234 4321 123 321 12 21 1 1

15th Dec 2017, 7:43 AM
poonam tigga
poonam tigga - avatar
11 Answers
+ 3
public class Main { public static void main(String args[]) { int a[]=new int[5]; a[0]=1; a[1]=2; a[2]=3; a[3]=4; a[4]=5; int len=a.length; int blank_space=0; while(len>=0) { for(int i=0;i<len;i++) { System.out.print(a[i]); } for(int j=1;j<=blank_space;j++) { System.out.print(" "); } for(int k=len-1;k>=0;k--) { System.out.print(a[k]); } System.out.println(""); --len; blank_space+=2; } } }
15th Dec 2017, 8:23 AM
Rishi Anand
Rishi Anand - avatar
+ 2
tnkew
15th Dec 2017, 11:24 AM
poonam tigga
poonam tigga - avatar
+ 1
i'll show you coding wait
15th Dec 2017, 7:50 AM
poonam tigga
poonam tigga - avatar
+ 1
wait i'm typing the code
15th Dec 2017, 8:05 AM
poonam tigga
poonam tigga - avatar
+ 1
import java.io.*; import java.lang.*; class rbs { public static void main(String args[])throws IOException { InputStreamReader ob=new InputStreamReader(System.in); BufferedReader ob1=new BufferedReader(ob); int i,j,k,m; int m=10; for(i=5;i>=1;i--) { for(k=1;k<=m;k++) { System.out.print(""); } for(j=1;j<=i;j++) { System.out.print(j+" "); } m--; System.out.println(""); } m=m+1; for(i=1;i<=5;i++) { for(j=1;j<=m;j++) { System.out.println(" "); } for(k=1;k<=i;k++) { System.out.println(k+""); } m++; System.out.println(" "); } } }
15th Dec 2017, 8:19 AM
poonam tigga
poonam tigga - avatar
+ 1
using nested for loop only
15th Dec 2017, 8:59 AM
poonam tigga
poonam tigga - avatar
+ 1
ok
15th Dec 2017, 9:02 AM
poonam tigga
poonam tigga - avatar