Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include "bairstowmetodo.h"
- using namespace std;
- int main()
- {
- //Definiciones
- double polinomio[] = {1,-3.5,2.75,2.125,-3.875,1.25};
- //Apuntadores
- double* raizR, * raizI;
- int n = sizeof(polinomio) / sizeof(double) - 1, x = 0;
- raizR = new double[n];
- raizI = new double[n];
- //Aplicacion del metodo
- metBair metodo(polinomio, n);
- metodo.bairstow();
- raizR = metodo.getRaizR();
- raizI = metodo.getRaizI();
- //Resultados del metodo
- cout << "Raices: " << endl;
- for (int i = 0; i < n; i++)
- {
- if (raizI[i] > 0) //Raiz mayor a 0
- cout << raizR[i] << " +i " << raizI[i] << endl;
- else if (raizI[i] < 0) //Raiz menor a 0
- cout << raizR[i] << " -i " << -raizI[i] << endl;
- else
- if (x >= 0) { //If para numero de raiz
- cout << "x" << x << ": " << raizR[i] << endl;
- x++;
- }
- else { x++; }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement