close
LV超3A名牌購物網
請參考我的做法
import java.util.*;
public class Y8893 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
while (true) {
System.out.print("Enter n ('0' for exit): ");
int n = scan.nextInt();
if (n == 1) func1(9);
else if (n == 2) {
System.out.print("Enter i: ");
int i = scan.nextInt();
func1(i);
} else if (n == 0) {
break;
}
}
}
public static void func1(int n) {
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
if (i + j > (n+1)) break;
System.out.print(i + "*" + j + "=" + (i*j) + "\t");
}
System.out.println();
}
}
}
全站熱搜
留言列表