Simple question
Description
Enter a number, output it in reverse order, and output the product of each bit.
Input Description: a positive integer within the int range.
Output Description: two numbers separated by spaces. The first number is the inverted value, and the second number is the product of each digit.
Example: 134
Sample output: 431 12
Solution: simplified and simplified. It is much easier to simply read strings.
PS: You don't need to worry about the meaning of the question here. It is not particularly emphasized that the output is in the format of a number, so there can be a leading 0
Void main () {int D; CIN> D; ostringstream OS; OS <D; string S = OS. STR (); int Len = S. size (); int res = 1; int I; for (I = len-1; I> = 0; I --) {cout <s [I]; res * = (s [I]-'0');} cout <''<res <Endl ;}
You can also think that the string type number is directly input, rather than the int type number. In this way, you can omit the code for converting from int to string, and if it starts with 0, it will not be omitted. You need to check the question during the exam.