思路:
1.利用数组反转函数,将int转化为string(
to_string
)
2.reverse(s.begin(),s.end())
反转,s.end()是最后一位的下一位
3.再将string(stoi()
)转化为int型输出
注意:
最后输出是数字!
代码:
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
int c=a*b;
//int->string
string s = to_string(c);
//反转
reverse(s.begin(),s.end());
int d = stoi(s);
cout<<d;
return 0;
}