早教吧 育儿知识 作业答案 考试题库 百科 知识分享

英语翻译programrq598;varm,n,i,j,q,l,r,k:longint;a,b:array[0..1100]oflongint;procedurehave(r:longint);varx:longint;begink:=0;forx:=1tomdoifb[x]=rthenk:=1;end;beginreadln(m,n);fori:=1tondoread(a[i]);q:=0;fori:=1tondobeginforj:=

题目详情
英语翻译
program rq598;
var
m,n,i,j,q,l,r,k:longint;
a,b:array[0..1100] of longint;
procedure have(r:longint);
var
x:longint;
begin
k:=0;
for x:=1 to m do
if b[x]=r then k:=1;
end;
begin
readln(m,n);
for i:=1 to n do read(a[i]);
q:=0;
for i:=1 to n do
begin
for j:=1 to m do
begin
if (a[i]b[j]) and (b[j]=0) then
begin
b[j]:=a[i];
inc(q);
break;
end else
begin
have(a[i]);
if (k=0) and (b[m]0) then
begin
for l:=1 to (m-1) do b[l]:=b[l+1];
b[m]:=a[i];
inc(q);
end;
end;
end;
end;
write(q);
end.
▼优质解答
答案和解析
if (a[i]b[j]) and (b[j]=0) then//这里改成ORbeginb[j]:=a[i];inc(q);break;end elsebegin我不知道你的 for j:=1 to m dobeginif (a[i]b[j]) and (b[j]=0) then发挥了什么作用.好像跟HAVE(a[i])冲突了吧总感觉程序...