expected but "ELSE" foundprogram ex111;var a:array[1..100] of integer;n,i,ans,len,tmp,beg:integer;beginread(n);for i:=1 to n doread(a[i]);tmp:=0;ans:=0;len:=0;beg:=0;for i:=1 to n dobeginif tmp+a[i]>ans then beginans:=tmp+a[i];len:=i-beg;end;else if

来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/24 11:05:05
expectedbut"ELSE"foundprogramex111;vara:array[1..100]ofinteger;n,i,ans,len,tmp,beg:integer;beginread

expected but "ELSE" foundprogram ex111;var a:array[1..100] of integer;n,i,ans,len,tmp,beg:integer;beginread(n);for i:=1 to n doread(a[i]);tmp:=0;ans:=0;len:=0;beg:=0;for i:=1 to n dobeginif tmp+a[i]>ans then beginans:=tmp+a[i];len:=i-beg;end;else if
expected but "ELSE" found
program ex111;
var
a:array[1..100] of integer;
n,i,ans,len,tmp,beg:integer;
begin
read(n);
for i:=1 to n do
read(a[i]);
tmp:=0;
ans:=0;
len:=0;
beg:=0;
for i:=1 to n do
begin
if tmp+a[i]>ans then
begin
ans:=tmp+a[i];
len:=i-beg;
end;
else if (tmp+a[i]=ans) and (i-beg>len) then
len:=i-beg
if tmp+a[i]

expected but "ELSE" foundprogram ex111;var a:array[1..100] of integer;n,i,ans,len,tmp,beg:integer;beginread(n);for i:=1 to n doread(a[i]);tmp:=0;ans:=0;len:=0;beg:=0;for i:=1 to n dobeginif tmp+a[i]>ans then beginans:=tmp+a[i];len:=i-beg;end;else if
主要是else前面的end后面应该没有;号.
program ex111;
var
a:array[1..100] of integer;
n,i,ans,len,tmp,beg:integer;
begin
read(n);
for i:=1 to n do
read(a[i]);
tmp:=0;
ans:=0;
len:=0;
beg:=0;
for i:=1 to n do
begin
if tmp+a[i]>ans then
begin
ans:=tmp+a[i];
len:=i-beg;
end
else if (tmp+a[i]=ans) and (i-beg>len) then
len:=i-beg;
if tmp+a[i]