daily pastebin goal
35%
SHARE
TWEET

Untitled

a guest Jan 11th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>;
  2. using namespace std;
  3.  
  4. double *poly_div(double *a, double  *b, int deg_a, int deg_b)
  5. {
  6.     double *ab = new double[deg_a - deg_b + 1];
  7.     for (int i = 0; i != deg_a - deg_b + 1; i++)
  8.     {
  9.         ab[deg_a - deg_b - i] = a[deg_a - 1 - i] / b[deg_b - 1 ];
  10.         cout << a[deg_a - 1] << endl;
  11.         for (int j = 0; j != deg_b; j++)
  12.         {
  13.             a[deg_a - 1 - j] -= b[deg_b - 1 - j] * ab[deg_a - deg_b - i];
  14.         }
  15.     }
  16.     return (ab);
  17. }
  18.  
  19. int main ()
  20. {
  21.     const int deg_a = 5;
  22.     const int deg_b = 2;
  23.     double a[deg_a] = { 1, 1, 2, 1, 1};
  24.     double b[deg_b] = { 1, 1 };
  25.  
  26.     double *ab = poly_div(a, b, deg_a, deg_b);
  27.     for (int i = 0; i != deg_a - deg_b + 1; i++)
  28.     {
  29.         cout << ab[i] << "\t";
  30.     }
  31.     cout << endl;
  32.     system("pause");
  33.     return (0);
  34. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top