Advertisement
Guest User

asd

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