给定一个浮点数,求它的三次方跟
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <limits.h>
#include <stdlib.h>
#include <numeric>
#include<math.h>
using namespace std;
float binary_mid;
float x;
void binarycode(float min_num, float mid_num, float max_num){
binary_mid = mid_num;
if(max_num-min_num>1e-9){
if(mid_num*mid_num*mid_num<x){
min_num=mid_num;
mid_num=(min_num+max_num)/2;
binarycode(min_num, mid_num, max_num);
}
if(mid_num*mid_num*mid_num>x){
max_num=mid_num;
mid_num=(min_num+max_num)/2;
binarycode(min_num, mid_num, max_num);
}
}
return;
}
int main(){
cin>>x;
int f = 1;
if(x<0){
f=0;
x=-x;
}
binarycode(0, x/2, x);
if(f==0){
cout<<-binary_mid;
}
else cout<<binary_mid;
return 0;
}