SHARE
TWEET

Untitled

intsas Jun 3rd, 2020 681 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top