+ 1
How to print this pattern
1234554321 1234 4321 123 321 12 21 1 1
11 odpowiedzi
+ 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;
}
}
}
+ 2
tnkew
+ 1
i'll show you coding wait
+ 1
wait i'm typing the code
+ 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(" ");
}
}
}
+ 1
using nested for loop only
+ 1
ok