主题:[讨论]大家来帮我看看这个程序吧!!!!!
我才开始学Pascal,水平还不高。[em2]
我编了一个程序(附件也是这个程序):
program MathExam(input,output);
var i,a,b,c,d,s:integer;
x:array[1..4] of char;
procedure rightp(var sc:integer);
begin
sc:=sc+10;
writeln('Good! Your score is ',sc,' now.');
writeln;
end;
procedure wrongp;
begin
writeln('Sorry,you are wrong!');
writeln;
end;
begin
randomize;
x[1]:='+';x[2]:='-';
x[3]:='*';x[4]:='/';
for i:=1 to 10 do
begin
repeat
a:=trunc(random*9)+1;
b:=trunc(ramdom*9)+1;
c:=trunc(ramdom*4)+1;
until not (c=4 and a mod b<>0);
write(a,' ',x[c],' ',b,' = ');
readln(d);
case x[c] of
'+':if a+b=d then rightp(s) else wrongp;
'-':if a-b=d then rightp(s) else wrongp;
'*':if a*b=d then rightp(s) else wrongp;
'/':if a/b=d then rightp(s) else wrongp;
end;
end;
writeln('Your score is ',s,'!');
if s=100
then writeln('Very good!')
else
if s<100 and s>=60
then writeln('Good!')
else
if s<60 and s>30
then writeln('Just so so.')
else writeln('So bad!');
end.
因为这个程序里的好多东西老师还没教,我也不是很懂,所以请大家帮我看看这个程序有什么问题,谢啦~~
对了,这个程序TP编译时显示“Error 3: Unknown identifier.”(光标定在“b:=trunc(ramdom*9)+1;”这句“random”里的“r”字母。
(只要是有用的回答都加分)[em9]
我编了一个程序(附件也是这个程序):
program MathExam(input,output);
var i,a,b,c,d,s:integer;
x:array[1..4] of char;
procedure rightp(var sc:integer);
begin
sc:=sc+10;
writeln('Good! Your score is ',sc,' now.');
writeln;
end;
procedure wrongp;
begin
writeln('Sorry,you are wrong!');
writeln;
end;
begin
randomize;
x[1]:='+';x[2]:='-';
x[3]:='*';x[4]:='/';
for i:=1 to 10 do
begin
repeat
a:=trunc(random*9)+1;
b:=trunc(ramdom*9)+1;
c:=trunc(ramdom*4)+1;
until not (c=4 and a mod b<>0);
write(a,' ',x[c],' ',b,' = ');
readln(d);
case x[c] of
'+':if a+b=d then rightp(s) else wrongp;
'-':if a-b=d then rightp(s) else wrongp;
'*':if a*b=d then rightp(s) else wrongp;
'/':if a/b=d then rightp(s) else wrongp;
end;
end;
writeln('Your score is ',s,'!');
if s=100
then writeln('Very good!')
else
if s<100 and s>=60
then writeln('Good!')
else
if s<60 and s>30
then writeln('Just so so.')
else writeln('So bad!');
end.
因为这个程序里的好多东西老师还没教,我也不是很懂,所以请大家帮我看看这个程序有什么问题,谢啦~~
对了,这个程序TP编译时显示“Error 3: Unknown identifier.”(光标定在“b:=trunc(ramdom*9)+1;”这句“random”里的“r”字母。
(只要是有用的回答都加分)[em9]