Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- setlocale(LC_ALL, "ru");
- int x;
- cout << "Введите число: ";
- cin >> x;
- int sum = 0;
- for (; x > 0; x /= 10) {
- sum += x % 10;
- }
- cout << sum << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement