相关文章推荐
害羞的帽子  ·  linux基础命令:md5sum - ...·  1 年前    · 
逼格高的碗  ·  IIS 之 ...·  2 年前    · 
温柔的上铺  ·  python popleft example-掘金·  2 年前    · 
愉快的墨镜  ·  Python2.x 与 3​​.x ...·  2 年前    · 
[华为机试-C++]101 求解立方根

[华为机试-C++]101 求解立方根

8 个月前 · 来自专栏 华为机试 - C++
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
//f(x) = x^3-n = 0
double fcn(double x, double n) {
    return x * x * x - n;
double dfcn(double x, double n) {
    return 3 * x * x;
int main() {
    double n, x, x_last;
    cin >> n;
    x = n;
    while (1) {
        x_last = x;
        x = x - fcn(x,n) / dfcn(x,n);