初级题:
输入两个数字,将其反转后相加。要求
1) 两个非负数
2) 如果是最后一位为零,列如:1230这种形式的,反转之后编程321,再相加。
#include<iostream>
#include <string>
using namespace std;
void reverse(string& strSrc)
{
reverse(strSrc.begin(),strSrc.end());
}
int main()
{
string strSrc1;
string strSrc2;
cin>>strSrc1;
cin>>strSrc2;
reverse(strSrc1);
reverse(strSrc2);
int iDes1 = std::atoi(strSrc1.c_str());
int iDes2 = std::atoi(strSrc2.c_str());
int iSum = iDes1 + iDes2;
cout<< iSum <<endl;
system("pause");
}