源码
#include<iostream>
using namespace std;
int returnMutip(int n) {
int a[6] = { 0 };
int count = 0;
while (n > 0) {
a[count] = n % 10;
n /= 10;
count++;
}
bool firs = 0;
int mult = 0;
for (int i = 0; i < 6; i++) {
if ((a[i] != 0) && (firs == 0)) {
mult = a[i];
firs = 1;
}
else if ((a[i] != 0) && (firs != 0)) {
mult *= a[i];
}
}
return mult;
}
int main() {
int n;
cin >> n;
while (n>=10){
n = returnMutip(n);
}
cout << n;
return 0;
}
输入样例
123456
输出样例
4