# 运用向量求两个很长正数的和

2 6
10000000000000000000 10000000000000000000000000000000

8
10000000000010000000000000000000

```#include <iostream>
#include <vector>
using namespace std;

int min(int a, int b){
return a > b ? a : b;
}

int main(){
vector<int>v;

string str1 = "";
string str2 = "";
int temp = 0; //用来储存进位
int len1, len2;
int i = 0, j = 0, k = 0;
int sum = 0;
while(cin >> str1 >> str2){
v.clear();
len1 = str1.length();
len2 = str2.length();
i = len1 - 1;
j = len2 - 1;

len1 = max(len1, len2);

temp = 0;
while(i >= 0 && j >= 0){
sum = str1[i] - '0' + str2[j] - '0' + temp;
if(sum > 9){
temp = sum / 10;	//进位
}
//cout << sum << endl;
v.insert(v.begin(), sum % 10);
i--;
j--;
}

if(i < 0){
while(j >= 0){
sum = str2[j] - '0' + temp;
temp = 0;
if(sum > 9){
temp = sum / 10;	//进位
}
v.insert(v.begin(), sum % 10);
j--;
}
}

if(j < 0){
while(i >= 0){
sum = str1[i] - '0' + temp;
temp = 0;
if(sum > 9){
temp = sum / 10;	//进位
}
v.insert(v.begin(), sum % 10);
i--;
}

}

if(temp > 0){
v.insert(v.begin(), temp);
}

for(i = 0; i < v.size(); i++)
cout << v[i];
cout << endl;

}
}
```