Home > Back-end >  For bosses to help me this problem is how to do
For bosses to help me this problem is how to do

Time:09-25

Write a custom function, and an integer each digital product, and the main function to test,

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 of

Specific 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;
}
  • Related