Bài 55/2001 - Bài toán che mắt mèo
(Dành cho học sinh THCS và PTTH)
Program Che_Mat_meo;
Uses crt;
Const td=200;
Var i,j,n:integer;
out:string;
f:text;
Procedure Xuli;
Begin
for i:=1 to n do
begin
gotoxy(15,i+3);
for j:=1 to n do
begin
if (odd(i))and(odd(j)) then
textcolor(11);
if out<>'' then write(f,'M ')
else
begin
write('M ');
delay(td);
end;
end
else
textcolor(14);
if out<>'' then write(f,'o ')
begin
write('o ');
delay(td);
end;
writeln(f);
End;
BEGIN
Clrscr; textcolor(2);
Write('Nhap n= ');
Readln(n);
if n<=20 then out:=''
else
out:='matmeo.inp';
writeln('Mo File meo.inp de xem ket qua');
Assign(f,out);
Rewrite(f);
writeln(f,'(Chu M Ki hieu cho con meo, chu o ki hieu cho quan co)');
Xuli; writeln(f);
Writeln(f,'Tong cong co ',sqr((n+1) div 2),' con meo');
Close(f);
Readln;
END.
(Lời giải của bạn Đỗ Ngọc Sơn - Quảng Ninh)
Bạn đang xem bài 55/ - 100 DE TIN HSG CO DAP AN