L1-5 I won’t tell you (15 points)

Input format:

Enter two positive integers A and B not exceeding 1000 in the first line, separated by a space.

Output format:

Print the product of A and B backwards in one line.

Input sample:

5 7

Sample output:

53

Water question but pay attention to omit the leading 0 105 * 2 = 210 to output 12

#include <iostream>
#include <cstdio>
#include <string>
using namespace std;

int main()
{
    
    
	int a,b;
	cin >> a >> b;
	int ans;
	ans = a * b;
	int num = 0;

	while(ans)
	{
    
    
		int t = ans % 10;
		num = num * 10 + t; 
		ans /= 10;
	}
	cout << num;
	return 0;
}

Guess you like

Origin blog.csdn.net/moumoumouwang/article/details/109632444