Adding 2 huge numbers using vectors
I googled and found either useless shit or too complex, Can someone help me make a program using vectors to add 2 big numbers for example "9905803458 + 2942093480"
This is what I have so far (not working):
This is what I have so far (not working):
Code:
#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); // 123 becomes "123"
length = strNum.length(); // length = 3
string strNum1 = to_string(input2); // 123 becomes "123"
length1 = strNum.length(); // length = 3
if(length > length1){
strNum = to_string(input1); // 123 becomes "123"
length = strNum.length(); // length = 3
} else {
strNum1 = to_string(input2); // 123 becomes "123"
length1 = strNum.length(); // length = 3
}
cout << length;
string q = to_string(input2); // 123 becomes "123"
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;
}
