asgarlikanan

https://www.e-olymp.com/az/problems/20

Aug 6th, 2016
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
4CS 0.34 KB | None | 0 0
  1. #include <iostream>
  2. /*
  3.     Author: Kanan Asgarli
  4.     https://www.e-olymp.com/az/problems/20
  5. */
  6. using namespace std;
  7. int sum_of_digits(int n){
  8.     int sum = 0;
  9.     while(n > 0){
  10.         sum += n%10;
  11.         n = n/10;
  12.     }
  13.     return sum;
  14. }
  15. int n, ans;
  16. int main() {
  17.     cin>>n;
  18.     while(n > 0){
  19.         ans++;
  20.         n = n - sum_of_digits(n);
  21.     }
  22.     cout<<ans<<endl;
  23.     return 0;
  24. }
Add Comment
Please, Sign In to add comment