print: pop dx cmp dx, -1 je exit add dl, '0' int 21h jmp print
exit: mov ah, 01h int 21h ret
d dw 10 string db "1", 0
FPC
var s : string; i, c : integer; begin readln (s); c := 0; for i := 1 to length (s) do if (s[i] in ['0'..'9']) then inc (c, ord (s[i]) - ord ('0')); writeln (c); end.
program P1;
uses
crt;
var
A : array[1..3] of array [1..4] of longint;
i,j : integer;
begin
clrscr;
randomize;
writeln('Massiv : ');
for i := 1 to 3 do
begin
writeln('');
for j := 1 to 4 do
begin
A[i][j] := random(15)+random(5)-random(5);
write(A[i][j]:2,' ');
end;
end;
for i := 1 to 3 do
for j := 1 to 4 do
begin
if A[i][j] > 10 then
A[i][j] := i - j;
if (A[i][j] >= -5) and (A[i][j] <= 5) then
A[i][j] := sqr(i);
end;
writeln('');
writeln('');
writeln('Itogoviy massiv : ');
for i := 1 to 3 do
begin
writeln('');
for j := 1 to 4 do
begin
write(A[i][j]:2,' ');
end;
end;
readln;
readln;
end.
Fasm
org 100h
mov si, string
cld
my_loop:
lodsb
cmp al, 0
jz loop_exit
cmp al, '0'
jb my_loop
cmp al, '9'
ja my_loop
sub al, '0'
add bx, ax
jmp my_loop
loop_exit:
push -1
mov ax, bx
loop_push:
xor dx, dx
div [d]
push dx
cmp ax, 0
jne loop_push
mov ah, 2h
print:
pop dx
cmp dx, -1
je exit
add dl, '0'
int 21h
jmp print
exit:
mov ah, 01h
int 21h
ret
d dw 10
string db "1", 0
FPC
var
s : string;
i, c : integer;
begin
readln (s);
c := 0;
for i := 1 to length (s) do
if (s[i] in ['0'..'9']) then inc (c, ord (s[i]) - ord ('0'));
writeln (c);
end.