Ответ:
Python
number = input("Your number: ")
list_number = list(str(number))
x = int(len(list_number))
sum0 = 0
mult0 = 1
for a in range(x):
num = int(list_number[a])
sum0 = sum0 + num
mult0 = mult0 * num
a += 1
print(sum0)
print(mult0)
//с++
#include <iostream>
#include <cmath>
signed main()
{
setlocale(LC_ALL, "Rus");
int N, _sum = 0, _prod = 1;
std::cin >> N;
N = abs(N);
while (N > 0) {
_sum += N % 10;
_prod *= N % 10;
N /= 10;
}
std::cout << "Сумма: " << _sum << std::endl;
std::cout << "Произведение: " << _prod << std::endl;
return 0;
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Verified answer
Ответ:
Python
number = input("Your number: ")
list_number = list(str(number))
x = int(len(list_number))
sum0 = 0
mult0 = 1
for a in range(x):
num = int(list_number[a])
sum0 = sum0 + num
mult0 = mult0 * num
a += 1
print(sum0)
print(mult0)
Verified answer
//с++
#include <iostream>
#include <cmath>
signed main()
{
setlocale(LC_ALL, "Rus");
int N, _sum = 0, _prod = 1;
std::cin >> N;
N = abs(N);
while (N > 0) {
_sum += N % 10;
_prod *= N % 10;
N /= 10;
}
std::cout << "Сумма: " << _sum << std::endl;
std::cout << "Произведение: " << _prod << std::endl;
return 0;
}