>>9729595只有測試輸入asd245$@#$會不會過
沒改到49 < n < 53...二位數又爆了...QQ蝦.........
第三回合
[aa]
import java.util.Scanner;
public class PaintingPractice {
public static Scanner scanner = new Scanner(System.in);
public static void main(String[] args) {
String[] type = { "武器", "上色", "植物", "分鏡", "下半身", "肌肉", "服裝", "背部", "背景", "五官", "姿勢", "構圖", "綜合練習", "頭髮" };
int count = 14,input = 0;
String inputStr;
do {
System.out.println("今天要做幾項練習? (MAX:5)");
inputStr = scanner.nextLine();
if (intOrNot(inputStr)) {
input = Integer.parseInt(inputStr);
if (input < 1 || input > 5){
System.out.print("輸入錯誤");
input = 0;
continue;
}
System.out.println("本日練習:");
for (int i = 0; i < input; i++) {
int random = (int) (Math.random() * count--);
System.out.println((i + 1) + "." + type[random]);
for (int j = random; j < count; j++)
type[j] = type[j + 1];
}
}
else{
System.out.println("輸入錯誤");
}
} while (input < 1 || input > 5);
}
private static boolean intOrNot(String str) {
for (int i = 0; i < str.length(); i++) {
if (str.charAt(i) < 48 || str.charAt(i) > 58)
return false;
}
return true;
}
}
[/aa]