打印数字金字塔的 Java 程序。
以下是打印数字金字塔的 Java 程序。
示例
public class PrintingPyramids {
public static void main(String args[]){
int n,i,j,k=1;
n = 5;
for(i = 0; i<= n; i++) {
for(j = 0; j<= i; j++){
System.out.print(k+" ");
k++;
}
System.out.print("
");
}
}
}输出
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
广告
数据结构
网络
关系型数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP