急!用Java编写一个嵌套的for循环打印下列图案:

[复制链接]
查看11 | 回复4 | 2011-3-13 19:27:54 | 显示全部楼层 |阅读模式
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
帮帮忙哈!谢谢啊!

回复

使用道具 举报

千问 | 2011-3-13 19:27:54 | 显示全部楼层
public class Du { public static void main(String[] args) {int num = 5;//num用来控制你要打印的行数printDigits(num); } private static void printDigits(int num) {for(int i = 1; i <= num; i++){ for(int j = 1; j <= i; j++){
System.out.print(j + " "); } System.out.println();} }}---------------
回复

使用道具 举报

千问 | 2011-3-13 19:27:54 | 显示全部楼层
for(int i=1;i<=5:i++){for(int j=1;j<=i;j++){System.out.print(j+"
");}System.out.println();}
回复

使用道具 举报

千问 | 2011-3-13 19:27:54 | 显示全部楼层
public class Test2 { public static void main(String[] args) {int n=8;List list = new List();for (int i = 1; i < n; i++) { int a[] = new int[i-1]; for (int j =
回复

使用道具 举报

千问 | 2011-3-13 19:27:54 | 显示全部楼层
public class e{ public static void main(String args[]) {int i,j;
for(i=1;i<6;i++) { for(j=1;j<=i;j++)
{
System.out.printf(" "+j);
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行