Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define fastread()(ios_base::sync_with_stdio(false).cin.tie(NULL));
- #define pb push_back
- int cr=0;
- int counter(string s)
- {
- int sum=0;
- for(int i=0;i<s.size();i++)
- {
- sum+=s[i]-'0';
- }
- if(s.size()==1 && cr==0)cr=0;
- else cr++;
- if(sum>9)
- {
- s.clear();
- while(sum>0)
- {
- int x = sum%10;
- char c= x+'0';
- s.pb(c);
- sum/=10;
- }
- return counter(s);
- }
- //cr++;
- //if(sum==0 && cr==1)cr=0;
- return 1;
- }
- int main()
- {
- string s;
- cin>>s;
- int x= counter(s);
- cout<<cr<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement