reserve函数 atoi函数
- reserve函数可以实现字符串的反转 非常简单实用
- atoi函数可以实现把数字的字符串转换为 整数类型
两个函数经常放一块使用 能简化很多操作
You are given numbers a and b. Calculate the sum of a and reverse of b. A reverse of a number is a number which contains the same digits in reverse order. For example, reverse of 230 is 32, and reverse of 0 is 0.
Input
The input contains two integers a and b (0 ≤ a, b ≤ 109), separated by a single space. The numbers are given without leading zeros.
Output
Output the sum of a and reverse of b.
Examples
Input
5 15
Output
56
Input
73 9180
Output
892
代码如下:
#include <iostream>
#include <cstring>
#include <bits/stdc++.h>
using namespace std;
int main()
{
char a[103];
char b[100];
scanf("%s %s",a,b);
int len1=strlen(a);
int len2=strlen(b);
reverse(b,b+len2);
int x=atoi(a);
int y=atoi(b);
cout<<x+y<<endl;
return 0;
}