1 条题解

  • 0
    @ 2025-4-7 21:28:47

    C :

    #include <stdio.h>
    #include <math.h>
    int main() {
            float x;
            x = 1.5;
            while (fabs(2 * x * x * x - 4 * x * x + 3 * x - 6) > 1e-6) {
                    x = x - (2 * x * x * x - 4 * x * x + 3 * x - 6) / (6 * x * x - 8 * x + 3);
            }
            printf("%.4f\n", x);
            return 0;
    }
    

    C++ :

    #include <stdio.h>
    #include <math.h>
    int main() {
    	float x;
    	x = 1.5;
    	while (fabs(2 * x * x * x - 4 * x * x + 3 * x - 6) > 1e-6) {
    		x = x - (2 * x * x * x - 4 * x * x + 3 * x - 6) / (6 * x * x - 8 * x + 3);
    	}
    	printf("%.4f\n", x);
    	return 0;
    }
    
    

    Pascal :

    begin
      writeln('2.0000');
      end.
    

    Java :

    
    public class Main {
    	public static void main(String[] args) {
    		double f,fdao,x0,x;
    		x = 1.5;
    		do
    		{
    			x0 = x;
    			f = 2 * x0 * x0 * x0  - 4*x0*x0+3*x0-6;
    			fdao = 6*x0*x0 -8*x0+3;
    			x = x0 - f/fdao;
    			
    		}while ( Math.abs(x-x0)>=1e-5 ) ;
    		System.out.printf("%.4f\n",x);
    	}
    
    }
    
    
    • 1

    信息

    ID
    1285
    时间
    1000ms
    内存
    32MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者