Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cmath>
- #include <stdio.h>
- #include <iostream>
- using namespace std;
- int main (){
- float x1,y1,x2,y2;
- float u = 0.0;
- float l = -1.0;
- float m;
- for(int i = 0; i<10;i++){
- m=(u+l)*0.5;
- y1 = 3+6*((u+m)*0.5)+5*pow(((u+m)*0.5),2)+3*pow(((u+m)*0.5),3)+4*pow(((u+m)*0.5),4);
- x1 = (u+m)*0.5;
- y2 = 3+6*((l+m)*0.5)+5*pow(((l+m)*0.5),2)+3*pow(((l+m)*0.5),3)+4*pow(((l+m)*0.5),4);
- x2 = (l+m)*0.5;
- if(y1>y2){
- u=m;
- m=x2;
- }
- else if (y1 < y2){
- l=m;
- m=x1;
- }
- }
- cout << y1 << endl << x1;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement