level 5
中国郝帅哥
楼主
数字金字塔没输出,这么简单的题真是醉了,程序如下
program numtri;
uses math;
var
x:array[1..1000,1..1000] of longint;
y:array[1..1000] of longint;
a,b,c,d,e,f:longint;
begin
assign(input,'numtri,in');reset(input);
assign(output,'numtri.out');rewrite(output);
readln(a);
fillchar(x,sizeof(x),0);
fillchar(y,sizeof(y),0) ;
begin;
for b:=1 to a do
for c:=1 to b do
read(x[b,c]);
end;
begin;
for b:=1 to a-1 do
for c:=1 to b do
y[b]:=max(x[b,c]+x[b+1,c],x[b,c]+x[b+1,c+1]);
end;
for b:=1 to a do
e:=y[b]+y[b+1];
writeln(e);
close(input);
close(output);
end.
2015年01月22日 08点01分
1
program numtri;
uses math;
var
x:array[1..1000,1..1000] of longint;
y:array[1..1000] of longint;
a,b,c,d,e,f:longint;
begin
assign(input,'numtri,in');reset(input);
assign(output,'numtri.out');rewrite(output);
readln(a);
fillchar(x,sizeof(x),0);
fillchar(y,sizeof(y),0) ;
begin;
for b:=1 to a do
for c:=1 to b do
read(x[b,c]);
end;
begin;
for b:=1 to a-1 do
for c:=1 to b do
y[b]:=max(x[b,c]+x[b+1,c],x[b,c]+x[b+1,c+1]);
end;
for b:=1 to a do
e:=y[b]+y[b+1];
writeln(e);
close(input);
close(output);
end.