Advertisement
intsas

Untitled

Jun 3rd, 2020
772
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     setlocale(0, "");
  7.  
  8.     int n, m;
  9.     cout << "Введите число N: ";
  10.     cin >> n;
  11.     cout << "Введите число M: ";
  12.     cin >> m;
  13.  
  14.     int i;
  15.     for (i = n; i <= m; ++i) {
  16.         int number = i, count = 0, sum = 0;
  17.         while (number > 0) {
  18.             sum += number % 10;
  19.             ++count;
  20.             number /= 10;
  21.         }
  22.         cout << "Количество цифр в числе " << i << " равно " << count << endl;
  23.         cout << "Сумма цифр в числе " << i << " равна " << sum << endl;
  24.     }
  25.  
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement