日期:2014-05-20 浏览次数:20739 次
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("请输入一个0-9之间的数:");
int num = input.nextInt(10);
for (int i = num; i > 0; i--) {
for (int j = i; j > 0; j--) {
if (j > 1) {
System.out.print(j + "*");
} else {
System.out.print(j);
}
}
System.out.println();
}
}
}
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("请输入一个0-9之间的数:");
int num = input.nextInt();
if(num >= 10
------解决方案--------------------
num < 0) {
System.out.println("请输入0-9之间的数!");
return;
}
for (int i = num; i > 0; i--) {
for (int j = i; j > 0; j--) {
if (j > 1) {
System.out.print(j + "*");
} else {
System.out.print(j);
}
}
System.out.println();
}
}
}