PROGRAM In_Ma_Khoa;
USES crt;
VAR s:string;
Procedure Tong(x:string);
Var s2,i,s1,code:integer;
Begin
s2:=0;
for i:=1 to length(x) do
begin
val(x[i],s1,code);
s2:=s2+s1;
end;
write(s2);
End;
BEGIN
clrscr;
write('Nhap xau s:'); readln(s);
write('Ma khoa cua xau ki tu la:');
Tong(s);
readln;
END.
TONGXAU
const
fi='tongxau.inp';
fo='tongxau.out';
var
f:text;
a:array[1..32000] of char;
t,s,so,nul,i,n:integer;
procedure inp;
begin
assign(f,fi);
reset(F);
n:=0;
while not(eof(f)) do
begin
inc(n);
read(f,a[n]);
end;
close(F);
end;
procedure out;
begin
assign(f,fo);
rewrite(F);
i:=1 ;
s:=0;
while i<=n do
begin
t:=0;
while a[i] in ['0'..'9'] do
begin
val(a[i],so,nul);
t:=t*10+so;
inc(i);
end;
s:=s+t ;
inc(i);
end;
write(f,s);
close(f);
end;
BEGIN
INP;
OUT;
END.