viết chương trình làm ảo thuật đoán số mình đang nghĩ từ 1–>60
0 bình luận về “viết chương trình làm ảo thuật đoán số mình đang nghĩ từ 1–>60”
Program Ao_Thuat; uses crt; var n,m,i,kq,x,y: integer; h: string[1]; BEGIN n := 1; kq := 0; clrscr; textcolor (white); writeln(‘Ban hay nghi mot so bat ky tu 1 – 60’); Delay(1000); Write(‘Toi se doan so ban nghi la gi…’); readln; repeat clrscr; textcolor (lightblue+blink); Gotoxy(30,2);Write(‘A O T H U A T’); m:= n; x:= 1; y:= 1; textcolor (white); while m <= 60 do begin for i:= m to m + n-1 do begin inc(y); if i <= 60 then begin gotoxy(x*4,y*2); write(i); end; if y >= 5 then begin y:= 1;inc(x); end; end; m:=m+2*n; end; Gotoxy(4,12); textcolor (green); write(‘Co so ban nghi khong (c=co) & (k=khong)? ‘); readln(h); if h = ‘c’ then inc(kq,n); n:= n*2; until n > 32; clrscr; textcolor (lightred); if not (kq in [1..60]) then write(‘Vui long kiem tra lai!’) else write(‘Co phai so ban nghi la: ‘,kq); readln; END.
Program Ao_Thuat;
uses crt;
var n,m,i,kq,x,y: integer;
h: string[1];
BEGIN
n := 1;
kq := 0;
clrscr;
textcolor (white);
writeln(‘Ban hay nghi mot so bat ky tu 1 – 60’);
Delay(1000);
Write(‘Toi se doan so ban nghi la gi…’);
readln;
repeat
clrscr;
textcolor (lightblue+blink);
Gotoxy(30,2);Write(‘A O T H U A T’);
m:= n;
x:= 1;
y:= 1;
textcolor (white);
while m <= 60 do
begin
for i:= m to m + n-1 do
begin
inc(y);
if i <= 60 then
begin
gotoxy(x*4,y*2);
write(i);
end;
if y >= 5 then
begin
y:= 1;inc(x);
end;
end;
m:=m+2*n;
end;
Gotoxy(4,12);
textcolor (green);
write(‘Co so ban nghi khong (c=co) & (k=khong)? ‘);
readln(h);
if h = ‘c’ then inc(kq,n);
n:= n*2;
until n > 32;
clrscr;
textcolor (lightred);
if not (kq in [1..60]) then
write(‘Vui long kiem tra lai!’)
else write(‘Co phai so ban nghi la: ‘,kq);
readln;
END.
Hiệu ứng đầy đủ nhé bn