Toggle navigation
?
users online
Logout
Open hangout
Open chat for current file
:- use_module(library(clpfd)). najti_summu_iz_cheesla(Cheeslo, Summa) :- summa_tsyfr(Cheeslo, Tsyfry), kolichestvo_znakov(Cheeslo, Kolichestvo), !, Summa #= Cheeslo + Tsyfry + Kolichestvo. kolichestvo_znakov(Cheeslo, Kolichestvo) :- number_codes(Cheeslo, Znaki), length(Znaki, Kolichestvo). summa_tsyfr(Cheeslo, Tsyfry) :- number_codes(Cheeslo, Kody), cheeslah(Kody, Cheeslah), sum_list(Cheeslah, Tsyfry). cheeslah([], []). cheeslah([45, Kod|Kody], [-Cheeslo|Cheeslah]) :- number_codes(Cheeslo, [Kod]), cheeslah(Kody, Cheeslah). cheeslah([Kod|Kody], [Cheeslo|Cheeslah]) :- number_codes(Cheeslo, [Kod]), cheeslah(Kody, Cheeslah). main :- writeln('Введите число:'), read(Cheeslo), !, najti_summu_iz_cheesla(Cheeslo, Summa), write('Сумма равна: '), writeln(Summa). :- main.