Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Polinomio& operator*(Polinomio& a, Polinomio& b)
- {
- Polinomio mult;
- a.ordenar_Polinomio();
- b.ordenar_Polinomio();
- if (a.cantidad > b.cantidad)
- {
- for (int i = 0; i < a.cantidad; i++)
- {
- for (int j = 0; j < b.cantidad; j++)
- {
- mult.coeficientes[j] = a.coeficientes[i] * b.coeficientes[j];
- if (a.exponentes[i] == b.exponentes[j])
- {
- mult.exponentes[j] = b.exponentes[j];
- }
- }
- }
- }
- if (a.cantidad < b.cantidad)
- {
- for (int i = 0; i < a.cantidad; i++)
- {
- for (int j = 0; j < b.cantidad; j++)
- {
- mult.coeficientes[j] = b.coeficientes[i] * a.coeficientes[j];
- if (b.exponentes[i] == a.exponentes[j])
- {
- mult.exponentes[j] = a.exponentes[j];
- }
- }
- }
- }
- int cantidad2;
- for (int i = 0; i < 30; i++)
- {
- if (mult.coeficientes[i] != 0)
- {
- cantidad2++;
- }
- }
- mult.cantidad = cantidad2;
- return mult;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement