文章
27
粉丝
86
获赞
10
访问
29.8k
C++
同样可以AC
注意最高位进位情况
例如:999 999
#include <iostream>
#include <string>
#include <vector>
using namespace std;
void add(string num1, string num2){
int len1, len2, maxLen;
len1 = num1.size();
len2 = num2.size();
maxLen = max(len1, len2);
vector<char> num1S;
vector<char> num2S;
// cout << len1 << " " << len2 << " " << maxLen << endl;
for(int i = 0; i < maxLen - len1; i++){
num1S.push_back('0');
}
for(int i = 0; i < maxLen - len2; i++){
num2S.push_back('0');
}
string::iterator sit;
for(sit = num1.begin(); sit != num1.end(); sit++){
num1S.push_back(*sit);
}
for(sit = num2.begin(); sit != num2.end(); sit++){
num2S.push_back(*sit);
}
// cout << num1S.size() << " " << num2S.size() << endl;
vector<char> result(maxLen);
vector<char>::reverse...
登录后发布评论
暂无评论,来抢沙发