pascal题目,高手请进,对了加15分

2025-03-07 03:45:39
推荐回答(1个)
回答1:

var n,m,i,sa,sb:longint;
a,b:array[1..100] of integer;
begin
//assign(input,'snooker.in'); reset(input);
//assign(output,'snooker.out'); rewrite(output);
readln(n,m);
for i:=1 to n do
begin
read(a[i]);
sa:=sa+a[i];
end;
for i:=1 to m do
begin
read(b[i]);
sb:=sb+b[i];
end;
if a[n]=0 then sb:=sb+4;
if b[m]=0 then sa:=sa+4;
for i:=1 to n do
begin
if a[i]=1 then
if a[i+1]=1 then
begin
sa:=sa-1;
sb:=sb+4;
end;
end;
for i:=1 to m do
begin
if b[i]=1 then
if b[i+1]=1 then
begin
sb:=sb-1;
sa:=sa+4;
end;
end;
writeln(sa,' ',sb);
// close(output);
// close(input);
end.

ac了。lz请采纳。