Guest User

Untitled

a guest
Mar 24th, 2019
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. // C++ program to compute
  2. // factorial of big numbers
  3. #include <iostream>
  4. #include <vector>
  5. #include <algorithm>
  6. #include <iterator>
  7. using namespace std;
  8. vector<int> liczba1;
  9. vector<int> liczba2;
  10. vector<int> wynik;
  11.  
  12. #define MAXINT 2147483647
  13. #define MAX 9999
  14. //rozbijam dane wejsciowe do vectorow by mozna byla latwiej nimi manipulowac
  15. void split_to_vector(int a, int b, vector<int> &v1, vector<int> &v2){
  16. v1.push_back(a%10000);
  17. v1.push_back(a/10000);
  18. v2.push_back(b%10000);
  19. v2.push_back(b/10000);
  20. return;
  21. }
  22.  
  23. void display_vector(const vector<int> &v)
  24. {
  25. copy(v.begin(), v.end(),
  26. ostream_iterator<int>(std::cout, " "));
  27. }
  28.  
  29. void multiplication(vector<int> &wynik, vector<int> &v1, vector<int> &v2){
  30. int temp=0, vector_size1 = 0,vector_size2 = 0;
  31. vector_size1 = liczba1.size();
  32. vector_size2 = liczba2.size();
  33.  
  34. for (int i = 0; i < vector_size1+vector_size2; i++)
  35. wynik.push_back(0);
  36.  
  37. for (int i = 0; i < vector_size1; i++){
  38. for (int j = 0; j < vector_size2; j++){
  39. temp= liczba2[j] * liczba1[i];
  40. cout << temp << endl;
  41. wynik[j+i]=+ (temp%10000);
  42. wynik[j+i+1]=+ (temp/10000);
  43. cout << "temp% " << temp%10000 << endl;
  44. cout << "temp/ " << temp/10000 << endl;
  45. }
  46. // trzeba dodac warunek wprzypadku gdyby wartosc wychodzila poza pozycj
  47. }
  48.  
  49. /*temp = liczba1[0]*liczba2[0];
  50. wynik.push_back(temp%10000);
  51. wynik.push_back(temp/10000);
  52. temp = liczba1[0]*liczba2[1];
  53. wynik[1] = wynik[1] + temp%10000;
  54. wynik[1] = wynik[1] + temp%10000;
  55. temp = liczba1[1]*liczba2[1];
  56. wynik[1] = wynik[1] + temp%10000;
  57. wynik.push_back(temp/10000);*/
  58. return;
  59. }
  60.  
  61. int main() {
  62. int exponent = 100;
  63. int base = 20;
  64. int intlo1= 783849;
  65. int intlo2= 443717;
  66. split_to_vector(intlo1, intlo2, liczba1, liczba2);
  67. multiplication(wynik, liczba1, liczba2);
  68.  
  69.  
  70. display_vector(wynik);
  71.  
  72. return 0;
  73. }
Advertisement
Add Comment
Please, Sign In to add comment