* Chỉ muốn có kết quả (thì không có đệ quy)
type kmang=array[-5..100,-5..100] of longint;
var fi,fo:text;
n,i,j:longint;
a,b:kmang;
procedure ktn;
begin
assign(fi,'robot.inp');
assign(fo,'robot.out');
{$I-} reset(fi); {$I+}
if ioresult<>0 then
begin
rewrite(fi);
reset(fi);
end;
readln(fi,n);
for i:=1 to n do
begin
for j:=1 to n do
read(fi,a[i,j]);
readln(fi);
end;
for i:=0 to n+1 do
for j:=0 to n+1 do b[i,j]:=999999;
close(fi); rewrite(fo);
end;
function min(x,y:longint):longint;
begin
min:=x;
if y<x then min:=y;
end;
procedure taomang;
begin
b[1,1]:=a[1,1];
for i:=1 to n do
for j:=1 to n do
if (i=1) and (j=1) then write('')
else b[i,j]:=a[i,j]+min(b[i,j-1],b[i-1,j]);
writeln(fo,b[n,n]);
end;
BEGIN
ktn; taomang;
close(fo);
END.
* Tìm cả đường đi (có đệ quy để truy vết)
type kmang=array[-5..100,-5..100] of longint;
var fi,fo:text;
n,i,j:longint;
a,b:kmang;
procedure ktn;
begin
assign(fi,'robot.inp');
assign(fo,'robot.out');
{$I-} reset(fi); {$I+}
if ioresult<>0 then
begin
rewrite(fi);
reset(fi);
end;
readln(fi,n);
for i:=1 to n do
begin
for j:=1 to n do
read(fi,a[i,j]);
readln(fi);
end;
for i:=0 to n+1 do
for j:=0 to n+1 do b[i,j]:=999999;
close(fi); rewrite(fo);
end;
function min(x,y:longint):longint;
begin
min:=x;
if y<x then min:=y;
end;
procedure taomang;
begin
b[1,1]:=a[1,1];
for i:=1 to n do
for j:=1 to n do
if (i=1) and (j=1) then write('')
else b[i,j]:=a[i,j]+min(b[i,j-1],b[i-1,j]);
writeln(fo,b[n,n]);
for i:=1 to n do
begin
for j:=1 to n do
write(fo,B[i,j]:5);
writeln(fo);
end;
end;
procedure truyvet(i,j:longint);
begin
if (i=1) and (j=1) then write('')
else
if b[i,j-1]<b[i-1,j] then truyvet(i,j-1)
else truyvet(i-1,j);
write(fo,a[i,j],' ');
end;
BEGIN
ktn; taomang;
truyvet(n,n);
close(fo);
END.
Tin học, tiếng Anh: informatics, tiếng Pháp: informatique, là một ngành khoa học chuyên nghiên cứu quá trình tự động hóa việc tổ chức, lưu trữ, xử lý và truyền dẫn thông tin của một hệ thống máy tính cụ thể hoặc trừu tượng (ảo). Với cách hiểu hiện nay, tin học bao hàm tất cả các nghiên cứu và kỹ thuật có liên quan đến việc mô phỏng, biến đổi và tái tạo thông tin.
Nguồn : Wikipedia - Bách khoa toàn thưLớp 9 - Là năm cuối ở cấp trung học cơ sở, sắp phải bước vào một kì thi căng thẳng và sắp chia tay bạn bè, thầy cô và cả kì vọng của phụ huynh ngày càng lớn mang tên "Lên cấp 3". Thật là áp lực nhưng các em hãy cứ tự tin vào bản thân là sẻ vượt qua nhé!
Nguồn : ADMIN :))Xem thêm tại https://loigiaisgk.com/cau-hoi or https://giaibtsgk.com/cau-hoi
Copyright © 2021 HOCTAPSGK