翻译成Pascal语言 10
2个回答
展开全部
program FT;
uses crt;
var
dp:array[0..24][0..3500] of integer;
v,a:array[0..25] of integer;
i,j,k,n,sum:integer;
begin
read(sum,n);
for i:=1 to n do read(v[i]);
for i:=1 to n do
for j:=1 to sum do begin
dp[i][j]:=dp[i-1][j];
if v[i]<=j then
if dp[i-1][j]>(dp[i-1][j-v[i]]+v[i]) then
dp[i][j]:=dp[i-1][j];
else then
dp[i][j]:=dp[i-1][j-v[i]]+v[i];
end;
write(dp[n][sum]);
readkey();
end.
第二个请另外提问。
uses crt;
var
dp:array[0..24][0..3500] of integer;
v,a:array[0..25] of integer;
i,j,k,n,sum:integer;
begin
read(sum,n);
for i:=1 to n do read(v[i]);
for i:=1 to n do
for j:=1 to sum do begin
dp[i][j]:=dp[i-1][j];
if v[i]<=j then
if dp[i-1][j]>(dp[i-1][j-v[i]]+v[i]) then
dp[i][j]:=dp[i-1][j];
else then
dp[i][j]:=dp[i-1][j-v[i]]+v[i];
end;
write(dp[n][sum]);
readkey();
end.
第二个请另外提问。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询