Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- /*
- Author: Kanan Asgarli
- https://www.e-olymp.com/az/problems/20
- */
- using namespace std;
- int sum_of_digits(int n){
- int sum = 0;
- while(n > 0){
- sum += n%10;
- n = n/10;
- }
- return sum;
- }
- int n, ans;
- int main() {
- cin>>n;
- while(n > 0){
- ans++;
- n = n - sum_of_digits(n);
- }
- cout<<ans<<endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment