猜数字的pascal 哪里错了啊?

来源:百度知道 编辑:UC知道 时间:2024/06/17 00:57:48
program zjh(input,output);
var
z, j, h: integer;
begin
randomize;
z:=random(100);
j:=0;
repeat
write('please input a number(0-11):');
read(h);
j:=j+1;
if h>z then writeln('too big, please try again! ');
if h<z then writeln('too small, please try again! ');
if h=z then writeln('you are right! ');
until(h=z)or(j=10);
if(j=10)and(h <> z)then;
writeln('you are fail, the number is',z);
end.
运行以后在十次之内而且答错正常,一答对就自动关闭。超过十次也就自动关闭...怎么回事啊
if h=z then writeln('you are right! ');

if(j=10)and(h <> z)then;
writeln('you are fail, the number is',z);
似乎这两个地方用问题......
'you are fail, the number is',z
'you are right
这两句根本就没出来过哦....

既然答对了当然自动关闭!
而且你的程序限制了必须要在10次之内猜到,超过了10次当然就关闭了!
另外,你的程序并没有错,只是有一点小问题
if(j=10)and(h <> z)then;
writeln('you are fail, the number is',z);
end.
你不是判断完之后加了分号,就是说你的判断根本没用!
应该是:
if(j=10)and(h <> z)then
writeln('you are fail, the number is',z);
end.

我不知道你的机为什么会这样
但我的机就能看到
总之你把我的那段和你的那段对调就可以了
引用一下,自己懒得打,另附自己程序:
var a,b,d:integer;
c:boolean;
begin
randomize;b:=random(100);
repeat;
write('Please write a number 1-100:');
readln(a);d:=d+1;
if a<b then writeln('No,it is smaller');
if a>b then writeln('No,it is bigger');
if a=b then writeln('You are right thank you play QQ:932976500');
until (d=10)or(a=b);
if d=10 then writeln('Game Over');
readln;
end.

既然答对了当然自动关闭!
而且你的程序限制了必须要在10次之内猜到,超过了10次当然就关闭了!
另外,你的程序并