4月13日打卡
打卡c++趣味练
6.

#include<bits/stdc++.h> using namespace std; int nuidun(double a, double b, double c, double d){ double x0, f, fd, x = 1.5; do{ x0 = x; f = a * x0 * x0 * x0 + b * x0 * x0 + c * x0 + d; fd = 3 * a * x0 * x0 + 2 * b * x0 + c; x = x0 - f / fd; }while(fabs( x - x0) >= 1e-5); return x; } int main(){ double a, b, c, d, x = 1.5; double r; cin >> a >> b >> c >> d; r = nuidun(a, b, c, d); cout << r; return 0; }
今天写的好慢
浙公网安备 33010602011771号