Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // C++ program to compute
- // factorial of big numbers
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <iterator>
- using namespace std;
- vector<int> liczba1;
- vector<int> liczba2;
- vector<int> wynik;
- #define MAXINT 2147483647
- #define MAX 9999
- //rozbijam dane wejsciowe do vectorow by mozna byla latwiej nimi manipulowac
- void split_to_vector(int a, int b, vector<int> &v1, vector<int> &v2){
- v1.push_back(a%10000);
- v1.push_back(a/10000);
- v2.push_back(b%10000);
- v2.push_back(b/10000);
- return;
- }
- void display_vector(const vector<int> &v)
- {
- copy(v.begin(), v.end(),
- ostream_iterator<int>(std::cout, " "));
- }
- void multiplication(vector<int> &wynik, vector<int> &v1, vector<int> &v2){
- int temp=0, vector_size1 = 0,vector_size2 = 0;
- vector_size1 = liczba1.size();
- vector_size2 = liczba2.size();
- for (int i = 0; i < vector_size1+vector_size2; i++)
- wynik.push_back(0);
- for (int i = 0; i < vector_size1; i++){
- for (int j = 0; j < vector_size2; j++){
- temp= liczba2[j] * liczba1[i];
- cout << temp << endl;
- wynik[j+i]=+ (temp%10000);
- wynik[j+i+1]=+ (temp/10000);
- cout << "temp% " << temp%10000 << endl;
- cout << "temp/ " << temp/10000 << endl;
- }
- // trzeba dodac warunek wprzypadku gdyby wartosc wychodzila poza pozycj
- }
- /*temp = liczba1[0]*liczba2[0];
- wynik.push_back(temp%10000);
- wynik.push_back(temp/10000);
- temp = liczba1[0]*liczba2[1];
- wynik[1] = wynik[1] + temp%10000;
- wynik[1] = wynik[1] + temp%10000;
- temp = liczba1[1]*liczba2[1];
- wynik[1] = wynik[1] + temp%10000;
- wynik.push_back(temp/10000);*/
- return;
- }
- int main() {
- int exponent = 100;
- int base = 20;
- int intlo1= 783849;
- int intlo2= 443717;
- split_to_vector(intlo1, intlo2, liczba1, liczba2);
- multiplication(wynik, liczba1, liczba2);
- display_vector(wynik);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment