1 program Project16; 2 3 {$APPTYPE CONSOLE} 4 VAR 5 n,i,k,score,b,a:integer; 6 answer,c:real; 7 ch:char; 8 Begin 9 repeat 10 writeln('1.加法练习'); 11 writeln('2.减法练习'); 12 writeln('3.乘法练习'); 13 writeln('4.除法练习'); 14 writeln('5.退出系统'); 15 score:=0; {得分初值为零} 16 k:=0; {答对题数初值为零} 17 write('请选择练习项目:'); 18 readln(n); 19 writeln; 20 if n<>5 then 21 begin 22 if n=4 then writeln('结果保留两位小数'); {除法运算时提示用户要保留两位小数} 23 writeln; 24 for i:=1 to 10 do 25 begin 26 write('第',i,'题:'); 27 randomize; 28 a:=random(10)+1;{产生1~10内的随机数} 29 b:=random(10)+1; 30 case n of 31 1: begin 32 write(a,'+',b,'='); 33 read(answer); 34 if answer=a+b then {判断输入的答案与正确答案是否相等} 35 begin 36 score:=score+10; {正确则加10分} 37 k:=k+1; {记录答对的题数} 38 writeln(' ':15,'正确'); 39 end 40 else writeln(' ':15,'错误'); 41 end; 42 43 2: begin 44 write(a,'-',b,'='); 45 read(answer); 46 if answer=a-b then 47 begin 48 score:=score+10; 49 k:=k+1; 50 writeln(' ':15,'正确'); 51 end 52 else writeln(' ':15,'错误'); 53 end; 54 3: begin 55 write(a,'×',b,'='); 56 read(answer); 57 if answer=a*b then 58 begin 59 score:=score+10; 60 k:=k+1; 61 writeln(' ':15,'正确'); 62 end 63 else writeln(' ':15,'错误'); 64 end; 65 4: begin 66 write(a,'÷',b,'='); 67 read(answer); 68 c:=(round((a/b)*100))/100; 69 if answer=c then {正确答案保留两位小数} 70 begin 71 score:=score+10; 72 k:=k+1; 73 writeln(' ':15,'正确'); 74 end 75 else writeln(' ':15,'错误'); 76 end; 77 78 end; 79 end; 80 writeln; 81 write('你一个回答对了',k,'道题,','得了',score,'分。'); {输出测试结果} 82 if score>=90 then writeln('Very Good!') 83 else if score>=80 then writeln('Good!') 84 else if score>=70 then writeln('Well') 85 else if score>=60 then writeln('Pass!') 86 else writeln('Fail!'); 87 writeln; 88 write('你想继续选择练习项目吗?',' ':2,'(Y/N)',' ':4); {判断用户是否想继续测试} 89 readln; 90 read(ch); 91 writeln 92 end; 93 until (ch='N')OR(CH='n')or(n=5);{输入N或n则表示用户退出测试} 94 end.