本题有将int型转换为string,利用函数to_string()。另外就是输出开始不能是0,做除直到余数不为0就可以了,下面是完整的代码
#include<iostream>
#include<string>
using namespace std;
int main() {
int a, b, c;
string s;
cin >> a >> b;
c = a * b;
while (c % 10 == 0) {
c = c / 10;
}
s = to_string(c);
for (int i = s.length() - 1; i >= 0; i--) {
cout << s[i];
}
return 0;
}