[Algorithm] 모든자리수 반복곱하기
#include <iostream>
using namespace std;
int testcase;
unsigned long int num;
unsigned long int result;
int main()
{
cin >> testcase;
for(int i = 0; i < testcase;i++)
{
cin >> num;
while(num > 9)
{
int result = 1;
while (num != 0)
{
if(num % 10 != 0)
{
result *= num % 10;
}
else
{
result *= 1;
}
num = num / 10;
} //inner while
num = result;
}
cout << num << endl;
}
return 0;
}
댓글남기기