Java Program for Pyramid of Numbers:
public class Pyramid{
public static void main(String[]args){
int n=9;
for(int i=1;i<=n;i++){
for(int j=n−i;j>=1;j−−)
System.out.print(” ”);
for(int k=1;k<=i;k++)
System.out.print(k+” ”);
for(int p=i−1;p>=1;p−−)
System.out.print(p+” ”);
System.out.println();
}
}
}
public class Pyramid{
public static void main(String[]args){
int n=9;
for(int i=1;i<=n;i++){
for(int j=n−i;j>=1;j−−)
System.out.print(” ”);
for(int k=1;k<=i;k++)
System.out.print(k+” ”);
for(int p=i−1;p>=1;p−−)
System.out.print(p+” ”);
System.out.println();
}
}
}
This comment has been removed by the author.
ReplyDelete