Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int a,b,c,d;
- int sum = 1;
- int sum1 = 1;
- int sum2 = 1;
- int sum3 = 1;
- int br = 0;
- int number;
- cin >> number;
- if(number >= 0 && number <= 9)
- {
- cout << br << endl;
- return 0;
- }
- while(number > 0)
- {
- a = number % 10;
- sum = sum * a;
- number = number / 10;
- }
- br = br + 1;
- if(sum > 9)
- {
- while(sum > 0)
- {
- b = sum % 10;
- sum1 = sum1 * b;
- sum = sum / 10;
- }
- }else{
- cout << br << endl;
- return 0;
- }
- br = br + 1;
- if(sum1 > 9)
- {
- while(sum1 > 0)
- {
- d = sum1 % 10;
- sum2 = sum2 * d;
- sum1 = sum1 / 10;
- }
- }else{
- cout << br << endl;
- return 0;
- }
- br = br + 1;
- if(sum2 > 9)
- {
- while(sum2 > 0)
- {
- c = sum2 % 10;
- sum3 = sum3 * c;
- sum2 = sum2 / 10;
- }
- }else{
- cout << br << endl;
- return 0;
- }
- br = br + 1;
- cout << br << endl;
- }
- /*
- 39 --> 3 (because 3*9 = 27, 2*7 = 14, 1*4 = 4 and 4 has only one digit)
- 999 --> 4 (because 9*9*9 = 729, 7*2*9 = 126, 1*2*6 = 12, and finally 1*2 = 2)
- 4 --> 0 (because 4 is already a one-digit number)
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement