public class pyramid
{
public static void main(String[] args)
{
int i,j,c;
for(i=1; i<=3; i++)
{System.out.print("\n");
for(j=3; j>=i; j--)
{
System.out.print(" ");
}
for(c=1; c<=i; c++)
{
System.out.print(c);
}
for(int k=i-1; k>=1; k--)
System.out.print(k);
}
}
}
output
1
121
12321
{
public static void main(String[] args)
{
int i,j,c;
for(i=1; i<=3; i++)
{System.out.print("\n");
for(j=3; j>=i; j--)
{
System.out.print(" ");
}
for(c=1; c<=i; c++)
{
System.out.print(c);
}
for(int k=i-1; k>=1; k--)
System.out.print(k);
}
}
}
output
1
121
12321
No comments:
Post a Comment
SAY HELLO!!