[编程题]A+B
  • 热度指数:11846 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 64M,其他语言128M
  • 算法知识视频讲解
给定两个整数A和B,其表示形式是:从个位开始,每三位数用逗号","隔开。 现在请计算A+B的结果,并以正常形式输出。

输入描述:
输入包含多组数据数据,每组数据占一行,由两个整数A和B组成(-10^9 < A,B < 10^9)。


输出描述:
请计算A+B的结果,并以正常形式输出,每组数据占一行。
示例1

输入

-234,567,890 123,456,789
1,234 2,345,678

输出

-111111101
2346912
头像 燃烧的橘子
发表于 2023-03-10 20:55:41
#include <iostream> using namespace std; int func(string s) { string temp; for(int i=0;i<s.length();i++) { if(s[i]!=','& 展开全文
头像 路人萌Miranda
发表于 2022-03-16 11:25:42
#include <cstdio> #include <string> using namespace std; int main() { string A, B; while (cin >> A >> B) { long long a = 展开全文
头像 香泥乐铁汁
发表于 2024-03-07 09:35:40
// 利用string的erase删除',',只保留纯数字,然后再利用stoi函数将字符串转为数字,直接进行相加 #include "iostream" #include "string" using namespace std; int main(){ 展开全文
头像 在考古的小鱼干很有气魄
发表于 2023-03-05 11:40:03
#include <bits/stdc++.h> using namespace std; int main(){ string s1,s2; cin>>s1>>s2; int len1 = s1.size(),len2 = s2.size(); int 展开全文
头像 pinkbin
发表于 2023-02-20 17:31:48
#include <iostream> #include <sstream> #include <string> using namespace std; int my_stoi(string s) { stringstream ss; for 展开全文
头像 牛客7777779号
发表于 2023-03-09 20:19:28
测试用例位数比较低,可以直接转成int型进行计算。 #include <iostream> #include <cstring> #include <algorithm> #include <math.h> #include <string.h 展开全文
头像 wbc990512
发表于 2021-01-21 18:16:27
按照字符串读入,利用stdlib.h的库函数atol转换成long型直接进行相加 #include <stdio.h> #include <stdlib.h> #include<string.h> long Atol(char *s) { char st 展开全文
头像 软件2001-20206821-傅子文
发表于 2024-03-16 17:21:12
#include <stdio.h> #include <string.h> int main() { char a[15]; char b[15]; while (scanf("%s %s", &a, &b) ! 展开全文
头像 SStarry
发表于 2023-09-05 18:14:08
#include <iostream> #include <vector> using namespace std; string s1, s2; vector<int> add(vector<int> &a, vector<int& 展开全文
头像 bigbigcake
发表于 2024-03-11 10:36:55
#include <iostream> using namespace std; int main() { string s1, s2; while (cin >> s1 >> s2) { for (auto it = s1.be 展开全文