Vla_DOS

Untitled

Feb 3rd, 2023
1,003
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <iomanip>
  4. #include <random>
  5. #include <algorithm>
  6.  
  7. using namespace std;
  8.  
  9. int count(int n) {
  10.     int count = -1, t_n = n, sum = 0;
  11.  
  12.     while (n != 0)
  13.     {
  14.         sum += n % 10;
  15.         n /= 10;
  16.     }
  17.     while (t_n > 0)
  18.     {
  19.         count++;
  20.         t_n -= sum;
  21.     }
  22.  
  23.     return count;
  24. }
  25.  
  26.  
  27. int main() {
  28.     int n;
  29.     cin >> n;
  30.     cout << "count = " << count(n);
  31.  
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment