Advertisement
Saleh127

Untitled

May 5th, 2020
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. long long c=0,d,e=0,f,i,j,k,l,sum=0;
  6. string a;
  7. cin>>a;
  8. l=a.size();
  9. if(l==1)
  10. cout<<0<<endl;
  11. else
  12. {
  13. for(i=0; i<l; i++)
  14. {
  15. sum+=a[i]-48;
  16. }
  17. if(sum<10)
  18. cout<<1<<endl;
  19. else
  20. {
  21. d=sum;
  22. while(1)
  23. {
  24. e=0;
  25. c++;
  26. while(d!=0)
  27. {
  28. f=d%10;
  29. e=e+f;
  30. d/=10;
  31. }
  32. if(e<10)
  33. {
  34. cout<<c+1<<endl;
  35. break;
  36. }
  37. else
  38. d=e;
  39. }
  40. }
  41. }
  42. return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement