Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. #include <iostream>
  2. #include "bairstowmetodo.h"
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. //Definiciones
  8. double polinomio[] = {1,-3.5,2.75,2.125,-3.875,1.25};
  9. //Apuntadores
  10. double* raizR, * raizI;
  11. int n = sizeof(polinomio) / sizeof(double) - 1, x = 0;
  12. raizR = new double[n];
  13. raizI = new double[n];
  14.  
  15. //Aplicacion del metodo
  16. metBair metodo(polinomio, n);
  17. metodo.bairstow();
  18. raizR = metodo.getRaizR();
  19. raizI = metodo.getRaizI();
  20.  
  21. //Resultados del metodo
  22. cout << "Raices: " << endl;
  23. for (int i = 0; i < n; i++)
  24. {
  25. if (raizI[i] > 0) //Raiz mayor a 0
  26. cout << raizR[i] << " +i " << raizI[i] << endl;
  27. else if (raizI[i] < 0) //Raiz menor a 0
  28. cout << raizR[i] << " -i " << -raizI[i] << endl;
  29. else
  30. if (x >= 0) { //If para numero de raiz
  31. cout << "x" << x << ": " << raizR[i] << endl;
  32. x++;
  33. }
  34. else { x++; }
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement