AcWing 3606. A+B
原题链接
简单
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int N = 1e6 + 10;
int t, n, m, k, l, r, op, x, y;
int f[N];
bool flag;
//int dp[N][N];
void solve() {
string s1, s2;
int a, b;
bool fa,fb;
while (cin >> s1 >> s2) {
a = b = 0;
fa = fb = false;
if(s1[0]=='-')fa = true;
for (char ch : s1) {
if(ch>='0'&&ch<='9'){
a=a*10+(ch-'0');
}
}
if(s2[0]=='-')fb = true;
for (char ch : s2) {
if(ch>='0'&&ch<='9'){
b=b*10+(ch-'0');
}
}
if(fa)a*=-1;
if(fb)b*=-1;
// cout<<a<<" "<<b<<"\n";
cout <<(a+b)<<"\n";
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
solve();
return 0;
}