public static void getPic(){
System.out.println("请输入图形高度:");
Scanner s = new Scanner(System.in);
if(s.hasNextInt()){
int num = s.nextInt();
for(int i=0;i<num;i++){
for(int j=i;j<num;j++){
System.out.print(" ");
}
for(int k=0;k<2*i+1;k++){
System.out.print("*");
}
System.out.println("");
}
getCal();
}else{
System.out.println("拜托骚年,请输入数字!");
getPic();
}
}
public static int count = 0;
public static void getCal(){
Random r = new Random();
int num = r.nextInt(20)+1;
int num2 = (int)(Math.random()*100+1);
System.out.println("请计算乘法:"+num+"*"+num2+"=? ");
Scanner s = new Scanner(System.in);
int result = s.nextInt();
if(result==num*num2){
count++;
if(count==5){
System.out.println("恭喜你,智商过线。");
}else{
System.out.println("答对了,请继续!");
getCal();
}
}else{
System.out.println("错误,大脑短路了?从新来过吧!");
getPic();
}
}
public static void main(String[] args) {
getPic();
}