Guest User

Untitled

a guest
Dec 15th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. #include<iostream>
  2. #include<cmath>
  3. using namespace std;
  4.  
  5. int main(){
  6. int a,b,c,d;
  7. cout << "Entrez a, b, c et d: ";
  8. cin >> a >> b >> c >> d;
  9.  
  10. int xmin,xmax;
  11. float ymin,ymax,x;
  12. do {
  13. cout << "Entrez xmin et xmax: ";
  14. cin >> xmin >> xmax;
  15. ymin = ((a*pow(xmin,3)) + (b*(xmin,2)) + (c*xmin) + d);
  16. ymax = ((a*pow(xmax,3)) + (b*(xmax,2)) + (c*xmax) + d);
  17. cout << ymin << endl;
  18. cout << ymax << endl;
  19. }while(xmin >= xmax && ((ymin)*(ymax)) < 0);
  20.  
  21. float gauche, droite, y;
  22. gauche = xmin;
  23. droite = xmax;
  24. int i;
  25. i = 0;
  26. do {
  27. x = (gauche + droite)/2;
  28. y = ((a*pow(x,3))+(b*pow(x,2))+(c*x)+d);
  29. cout << "penis"
  30. if((gauche*y)>0) {
  31. gauche = x;
  32. }
  33. else {
  34. droite = x;
  35. }
  36. i = ++i;
  37. }while(fabs(y) >= pow(10,-7));
  38. cout << "La racine est " << x << " (trouvee en " << i << " iterations)" << endl;
  39. }
Add Comment
Please, Sign In to add comment