Advertisement
Guest User

asdaf

a guest
Feb 21st, 2020
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. Polinomio& operator*(const Polinomio& a, const Polinomio& b)
  2. {
  3. Polinomio mult;
  4.  
  5. if (a.cantidad > b.cantidad)
  6. {
  7. for (int i = 0; i < a.cantidad; i++)
  8. {
  9. for (int j = 0; j < b.cantidad; j++)
  10. {
  11. mult.coeficientes[j] = a.coeficientes[i] * b.coeficientes[j];
  12. mult.exponentes[j] = a.exponentes[i] + b.exponentes[j];
  13.  
  14. }
  15. }
  16. }
  17.  
  18. else
  19. {
  20. for (int i = 0; i < b.cantidad; i++)
  21. {
  22. for (int j = 0; j < a.cantidad; j++)
  23. {
  24. mult.coeficientes[i] = b.coeficientes[i] * a.coeficientes[j];
  25. mult.exponentes[i] = b.exponentes[i] + a.exponentes[j];
  26.  
  27. }
  28. }
  29. }
  30.  
  31. int cantidad2 = 0;
  32. for (int i = 0; i < 30; i++)
  33. {
  34. if (mult.coeficientes[i] != 0)
  35. {
  36. cantidad2++;
  37. }
  38. }
  39.  
  40. mult.cantidad = cantidad2;
  41. mult.ordenar_Polinomio();
  42. return mult;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement