发布网友 发布时间:2023-12-24 06:33
共1个回答
热心网友 时间:2024-08-01 13:56
程序已经完成,代码及运行图如下:
const num:array[0..9]of string[5]=('zero','one','two',
'three','four','five','six','seven','eight','nine');
var a,b,i,n:integer; c:char; ss:string; ans:array[1..100]of integer;
function readnum:integer;
var s:string[8]; j:integer;
begin
while ss[i] in [' ','+'] do inc(i);
s:='';
while ss[i]<>' ' do begin s:=s+ss[i]; inc(i) end;
for j:=0 to 9 do if s=num[j] then break;
readnum:=j;
end;
begin
readln(ss); i:=1;
repeat
a:=readnum;
if ss[i+1]<>'+' then a:=a*10+readnum;
b:=readnum;
if ss[i+1]<>'=' then b:=b*10+readnum;
if a+b>0 then begin inc(n); ans[n]:=a+b end else break;
if i=length(ss)-1 then begin readln(ss); i:=1 end;
until a+b=0;
for i:=1 to n do writeln(ans[i]);
end.