CodePudding user response:
Use the integer every % and/o out, at the same time times each, came out, with every bit as well as the thinking ofSpecific code is as follows, it is recommended that the original poster put something inside the while loop to understand well, very simple, this is very common
# include
using namespace std;
Int the product (int n) {
int result=1;
If (n==0) {
return 0;
}
While (n) {
The result *=n % 10;
N/a=10;
}
return result;
}
Int main ()
{
Cout & lt; & lt; The product (123) & lt; & lt; Endl;
return 0;
}