Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void pierwiastek();
- {
- double p[P] = {0};
- double q[P] = {0};
- int j = 0;
- for(int i = 1; i <= abs(wsp[N-1]); i++)
- {
- if((wsp[N-1]%i) == 0)
- {
- p[j] = i;
- j++;
- }
- }
- int k = 0;
- for(int i = 1; i <= abs(wsp[0]); i++)
- {
- if((wsp[0]%i) == 0)
- {
- q[k] = i;
- k++;
- }
- }
- double t[N][N];
- for(int i = 0; i < j; i++)
- {
- for(int r = 0; r < k; r++)
- t[i][r] = (double)(p[i]/q[r]);
- }
- for(int i = 0; i < j; i++)
- {
- for(int r = 0; r < k; r++)
- {
- if(Horner(t[i][r]) == 0.0)
- cout << t[i][r] << " jest pierwiastkiem" << endl;
- if(Horner(-t[i][r]) == 0.0)
- cout << (-t[i][r]) << " jest pierwiastkiem" << endl;
- }
- }
- }
- double Horner(double x)
- {
- double w = 0;
- int i = 0;
- for(i; i < N; i++)
- w = w*x + wsp[i];
- return w;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement