4个回答
2010-12-09
展开全部
program gangguan;
var f_in,f_out:text;
num,i,j:integer;
max_l,min_d,max_bh:longint; //长度l,直径d,编号bh;
guan:array[1..1000,1..3] of longint; //钢管数组用于存储所有数据;
begin
//以下是读取文件中的数据;
assign(f_in,'input.txt');
reset(f_in);
readln(f_in,num);
for i:=1 to num do
for j:=1 to 3 do read(f_in,guan[i,j]);
close(f_in);
//变量初始化;
max_l:=0;
min_d:=maxlongint;
max_bh:=0;
//先找出最大长度;
for i:=1 to num do
if guan[i,1]>max_l then max_l:=guan[i,1];
//比最大长度小的钢管数据清零;
for i:=1 to num do
if guan[i,1]<max_l then
begin
guan[i,1]:=0;
guan[i,2]:=0;
guan[i,3]:=0;
end;
//接着找最小直径;
for i:=1 to num do
if (guan[i,2] < min_d) and (guan[i,2]>0) then min_d:=guan[i,2];
//非最小直径的钢管数据清零;
for i:=1 to num do
if guan[i,2]>min_d then
begin
guan[i,1]:=0;
guan[i,2]:=0;
guan[i,3]:=0;
end;
//最后找最大编号;
for i:=1 to num do
if guan[i,3]>max_bh then max_bh:=guan[i,3];
//非最大编号的清零;
for i:=1 to num do
if guan[i,3]<max_bh then
begin
guan[i,1]:=0;
guan[i,2]:=0;
guan[i,3]:=0;
end;
//屏幕显示筛选后的钢管数据;
for i:=1 to num do
writeln(guan[i,1]:4,guan[i,2]:3,guan[i,3]:10);
//最大编号数据写回文件;
assign(f_out,'output.txt');
rewrite(f_out);
writeln(f_out,max_bh);
close(f_out);
end.
附测试数据(保存在input.txt文件中):
14
3000 50 872198442
3000 45 752498124
2000 60 765128742
3000 45 652278122
7500 16 457888215
4000 88 445886125
4000 75 545681555
3358 65 454588212
7500 56 477868218
3600 12 879546212
7500 16 457888215
3600 78 900004557
7500 16 374355457
2500 35 574125667
输出为:457888215
var f_in,f_out:text;
num,i,j:integer;
max_l,min_d,max_bh:longint; //长度l,直径d,编号bh;
guan:array[1..1000,1..3] of longint; //钢管数组用于存储所有数据;
begin
//以下是读取文件中的数据;
assign(f_in,'input.txt');
reset(f_in);
readln(f_in,num);
for i:=1 to num do
for j:=1 to 3 do read(f_in,guan[i,j]);
close(f_in);
//变量初始化;
max_l:=0;
min_d:=maxlongint;
max_bh:=0;
//先找出最大长度;
for i:=1 to num do
if guan[i,1]>max_l then max_l:=guan[i,1];
//比最大长度小的钢管数据清零;
for i:=1 to num do
if guan[i,1]<max_l then
begin
guan[i,1]:=0;
guan[i,2]:=0;
guan[i,3]:=0;
end;
//接着找最小直径;
for i:=1 to num do
if (guan[i,2] < min_d) and (guan[i,2]>0) then min_d:=guan[i,2];
//非最小直径的钢管数据清零;
for i:=1 to num do
if guan[i,2]>min_d then
begin
guan[i,1]:=0;
guan[i,2]:=0;
guan[i,3]:=0;
end;
//最后找最大编号;
for i:=1 to num do
if guan[i,3]>max_bh then max_bh:=guan[i,3];
//非最大编号的清零;
for i:=1 to num do
if guan[i,3]<max_bh then
begin
guan[i,1]:=0;
guan[i,2]:=0;
guan[i,3]:=0;
end;
//屏幕显示筛选后的钢管数据;
for i:=1 to num do
writeln(guan[i,1]:4,guan[i,2]:3,guan[i,3]:10);
//最大编号数据写回文件;
assign(f_out,'output.txt');
rewrite(f_out);
writeln(f_out,max_bh);
close(f_out);
end.
附测试数据(保存在input.txt文件中):
14
3000 50 872198442
3000 45 752498124
2000 60 765128742
3000 45 652278122
7500 16 457888215
4000 88 445886125
4000 75 545681555
3358 65 454588212
7500 56 477868218
3600 12 879546212
7500 16 457888215
3600 78 900004557
7500 16 374355457
2500 35 574125667
输出为:457888215
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
var a,b,c:longint;
begin
readln(a,b,c);
if (a>b)and(a>c) then
writeln(a)
else
if (b>a)and(b>c) then
writeln(b)
else
writeln(c);
end.
begin
readln(a,b,c);
if (a>b)and(a>c) then
writeln(a)
else
if (b>a)and(b>c) then
writeln(b)
else
writeln(c);
end.
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
var a,i,max:longint;
begin
read(a);
max:=a;{初始化}
for i:=2 to 3 do
begin
read(a);
if a>max then max:=a;{打擂台}
end;
writeln(max);
end.
begin
read(a);
max:=a;{初始化}
for i:=2 to 3 do
begin
read(a);
if a>max then max:=a;{打擂台}
end;
writeln(max);
end.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
跟布尔有关,说的再具体一点吧!谢
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询