Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cmath>
- using namespace std;
- int main(){
- int a,b,c,d;
- cout << "Entrez a, b, c et d: ";
- cin >> a >> b >> c >> d;
- int xmin,xmax;
- float ymin,ymax,x;
- do {
- cout << "Entrez xmin et xmax: ";
- cin >> xmin >> xmax;
- ymin = ((a*pow(xmin,3)) + (b*(xmin,2)) + (c*xmin) + d);
- ymax = ((a*pow(xmax,3)) + (b*(xmax,2)) + (c*xmax) + d);
- cout << ymin << endl;
- cout << ymax << endl;
- }while(xmin >= xmax && ((ymin)*(ymax)) < 0);
- float gauche, droite, y;
- gauche = xmin;
- droite = xmax;
- int i;
- i = 0;
- do {
- x = (gauche + droite)/2;
- y = ((a*pow(x,3))+(b*pow(x,2))+(c*x)+d);
- cout << "penis"
- if((gauche*y)>0) {
- gauche = x;
- }
- else {
- droite = x;
- }
- i = ++i;
- }while(fabs(y) >= pow(10,-7));
- cout << "La racine est " << x << " (trouvee en " << i << " iterations)" << endl;
- }
Add Comment
Please, Sign In to add comment