viết chương trình tìm phần tử cực tiểu (dùng file text và ct con nha)
0 bình luận về “viết chương trình tìm phần tử cực tiểu (dùng file text và ct con nha)”
program phantucuctieu; uses crt; var a:array [0..101,0..101] of longint; n,m,i,j,max,min:longint; f1,f2:text; procedure nhap; var i:integer; begin read(f1,m,n); for i:=1 to m do for j:=1 to n do begin read(f1,a[i,j]); end; end; {————————————–} procedure bug; var i,max:longint; begin for i:=0 to m+1 do for j:=0 to n+1 do if (i=0) or (j=0) or (i=m+1) or (j=n+1) then a[i,j]:=320; for i:=0 to m+1 do begin for j:=0 to n+1 do write(f2,a[i,j]:5); writeln(f2); end; end; {—————————————-} procedure ptct; var i,j:integer; begin for i:=1 to m do for j:=1 to n do if (a[i,j]<a[i-1,j-1]) and (a[i,j]<a[i-1,j]) and (a[i,j]<a[i-1,j+1]) and (a[i,j]<a[i,j-1]) and (a[i,j]<a[i,j+1]) and (a[i,j]<a[i+1,j-1]) and (a[i,j]<a[i+1,j]) and (a[i,j]<a[i+1,j+1]) then writeln(f2,'(‘,i,’,’,j,’)’); end; {—————————————–} begin assign(f1,’mang2c.inp’); reset(f1); assign(f2,’mang2c.out’); rewrite(f2); nhap; bug; ptct; close(f1); close(f2); end.
program phantieu; uses crt; var a:array [0..101,0..101] of longint; n,m,i,j,max,min:longint; f1,f2:text; procedure nhap; var i:integer; begin read(f1,m,n); for i:=1 to m do for j:=1 to n do begin read(f1,a[i,j]); end; end; {————————————–} procedure bug; var i,max:longint; begin for i:=0 to m+1 do for j:=0 to n+1 do if (i=0) or (j=0) or (i=m+1) or (j=n+1) then a[i,j]:=320; for i:=0 to m+1 do begin for j:=0 to n+1 do write(f2,a[i,j]:5); writeln(f2); end; Xin hay nhất
program phantucuctieu;
uses crt;
var a:array [0..101,0..101] of longint;
n,m,i,j,max,min:longint;
f1,f2:text;
procedure nhap;
var i:integer;
begin
read(f1,m,n);
for i:=1 to m do
for j:=1 to n do
begin
read(f1,a[i,j]);
end;
end;
{————————————–}
procedure bug;
var i,max:longint;
begin
for i:=0 to m+1 do
for j:=0 to n+1 do
if (i=0) or (j=0) or (i=m+1) or (j=n+1) then a[i,j]:=320;
for i:=0 to m+1 do
begin
for j:=0 to n+1 do
write(f2,a[i,j]:5);
writeln(f2);
end;
end;
{—————————————-}
procedure ptct;
var i,j:integer;
begin
for i:=1 to m do
for j:=1 to n do
if (a[i,j]<a[i-1,j-1]) and (a[i,j]<a[i-1,j]) and (a[i,j]<a[i-1,j+1])
and (a[i,j]<a[i,j-1]) and (a[i,j]<a[i,j+1]) and (a[i,j]<a[i+1,j-1])
and (a[i,j]<a[i+1,j]) and (a[i,j]<a[i+1,j+1]) then writeln(f2,'(‘,i,’,’,j,’)’);
end;
{—————————————–}
begin
assign(f1,’mang2c.inp’); reset(f1);
assign(f2,’mang2c.out’); rewrite(f2);
nhap;
bug;
ptct;
close(f1);
close(f2);
end.
program phantieu;
uses crt;
var a:array [0..101,0..101] of longint;
n,m,i,j,max,min:longint;
f1,f2:text;
procedure nhap;
var i:integer;
begin
read(f1,m,n);
for i:=1 to m do
for j:=1 to n do
begin
read(f1,a[i,j]);
end;
end;
{————————————–}
procedure bug;
var i,max:longint;
begin
for i:=0 to m+1 do
for j:=0 to n+1 do
if (i=0) or (j=0) or (i=m+1) or (j=n+1) then a[i,j]:=320;
for i:=0 to m+1 do
begin
for j:=0 to n+1 do
write(f2,a[i,j]:5);
writeln(f2);
end;
Xin hay nhất