uses wincrt;
function
convert (kar:char): integer;
begin
if kar='1' then convert:=1;
if kar='2' then convert:=2;
if kar='3' then convert:=3;
if kar='4' then convert:=4;
if kar='5' then convert:=5;
if kar='6' then convert:=6;
if kar='7' then convert:=7;
if kar='8' then convert:=8;
if kar='9' then convert:=9;
if kar='0' then convert:=0;
end;
var
score :string;
teamA,teamB:string;
scA,scB :integer;
i,j,n :integer;
begin
write ('Nama team ke-1: '); readln (teamA);
write ('Nama team ke-2: '); readln (teamB);
write ('Input score (',teamA,'-',teamB,'): '); readln (score);
scA:=0; scB:=0;
for i:=1 to length(score) do
begin
if score[i]='-' then
begin
n:=1;
for j:=i-1 downto 1 do
begin
scA:=scA+convert(score[j])*n;
n:=n*10;
end;
n:=1;
for j:=length(score) downto i+1 do
begin
scB:=scB+convert(score[j])*n;
n:=n*10;
end;
end;
end;
writeln ('Score untuk ',teamA,': ',scA);
writeln ('Score untuk ',teamB,': ',scB);
end.
Tidak ada komentar:
Posting Komentar