I need to use vectors to add 2 huge numbers, like this:
(Example:
3049358031
+1449238031
)
I searched everywhere, but I didn't find nothing.
(I have to use only vectors)
I have this code (which is not working):
#include <iostream>
#include <vector>
using namespace std;
int main()
{
vector <int> int1;
vector <int> int2;
vector <int> final;
int input1, input2;
int length = 0, length1 = 0;
cin >> input1 >> input2;
cout << "after cin" << endl;
string strNum = to_string(input1);
length = strNum.length();
string strNum1 = to_string(input2);
length1 = strNum.length();
if(length > length1){
strNum = to_string(input1);
length = strNum.length();
} else {
strNum1 = to_string(input2);
length1 = strNum.length();
}
cout << length;
string q = to_string(input2);
for(int i = 0; i < length; i++){
int1[i] = strNum.at(i);
int2[i] = strNum1.at(i);
}
cout << "after ye" << endl;
for(int i = 0; i < length; i++){
cout << " " << int1[i];
}
return 0;
}
Do I need to use vector<long long>
or vector<int>
?