#include<bits/stdc++.h>
using namespace std;
#define nd second
#define st first
#define pb push_back
typedef long long ll;
typedef long double ld;
void Solve()
{
int akt = 0;
string a, b, w;
cin >> a >> b;
reverse(a.begin(), a.end()); reverse(b.begin(), b.end());
for(int i = 0; i < (int)max(a.size(), b.size()); ++i)
{
if(i < (int)a.size()) akt += a[i] - '0';
if(i < (int)b.size()) akt += b[i] - '0';
w.pb((akt % 10) + '0'); akt /= 10;
}
if(akt > 0) w.pb(akt + '0');
reverse(w.begin(), w.end());
cout << w << "\n";
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
Solve();
return 0;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | #include<bits/stdc++.h> using namespace std; #define nd second #define st first #define pb push_back typedef long long ll; typedef long double ld; void Solve() { int akt = 0; string a, b, w; cin >> a >> b; reverse(a.begin(), a.end()); reverse(b.begin(), b.end()); for(int i = 0; i < (int)max(a.size(), b.size()); ++i) { if(i < (int)a.size()) akt += a[i] - '0'; if(i < (int)b.size()) akt += b[i] - '0'; w.pb((akt % 10) + '0'); akt /= 10; } if(akt > 0) w.pb(akt + '0'); reverse(w.begin(), w.end()); cout << w << "\n"; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); Solve(); return 0; } |
English