zoukankan      html  css  js  c++  java
  • rwkj 1308

    #include<stdio.h>
    main()
    {
        float x=2.5,y,x1=2.5,a,b,c,d,max,min;
        scanf("%f%f%f%f",&a,&b,&c,&d);
        do
        {
            y=x-(a*x*x*x+b*x*x+c*x+d)/(3*a*x*x+2*b*x+c);
            x=y;
        }while((a*x*x*x+b*x*x+c*x+d)!=0);
        printf("%.3f
    ",y);
    }
    View Code

    #include<stdio.h>
    main()
    {
        float x=2.5,y,x1=2.5,a,b,c,d,max,min;
        scanf("%f%f%f%f",&a,&b,&c,&d);
        do
        {
            y=x-(a*x*x*x+b*x*x+c*x+d)/(3*a*x*x+2*b*x+c);
            x=y;
        }while((a*x*x*x+b*x*x+c*x+d)!=0);
        printf("%.3f ",y);
    }

    #include <stdio.h>
    #include <math.h>
    int main()
    {
        float a,b,c,d,x,fx,x1,fx1;
        scanf("%f%f%f%f",&a,&b,&c,&d);
        x1=2.5;  
        do 
        {   x=x1;
            fx=a*x*x*x+b*x*x+c*x+d;
            fx1=3*a*x*x+b*2*x+c;
            x1=x-fx/fx1;
        } while (fabs(x1-x)>=1e-6);         
        printf("%.3f
    ",x);
        return 0;
    }
    View Code

    #include <stdio.h>
    #include <math.h>
    int main()
    {
        float a,b,c,d,x,fx,x1,fx1;
        scanf("%f%f%f%f",&a,&b,&c,&d);
        x1=2.5; 
        do
        {   x=x1;
            fx=a*x*x*x+b*x*x+c*x+d;
            fx1=3*a*x*x+b*2*x+c;
            x1=x-fx/fx1;
        } while (fabs(x1-x)>=1e-6);        
        printf("%.3f ",x);
        return 0;
    }


     

    #include <iostream>
    #include <iomanip>
    #include <cmath>
    using namespace std;
    int main(int argc, char *argv[])
    {
        float a,b,c,d,x,x1,f;
        cin>>a>>b>>c>>d;
        x1=2.5;
        do
        {
            x=x1;
         f=a*x1*x1*x1+b*x1*x1+c*x1+d;
         x1=x-f/(3*a*x1*x1+2*b*x1+c);
        }
        while (fabs(x-x1)>=1e-10);
        cout<<fixed<<setprecision(3)<<x<<endl;
        return 0;
    } 
    View Code

    #include <iostream>
    #include <iomanip>
    #include <cmath>
    using namespace std;
    int main(int argc, char *argv[])
    {
        float a,b,c,d,x,x1,f;
        cin>>a>>b>>c>>d;
        x1=2.5;
        do
        {
            x=x1;
         f=a*x1*x1*x1+b*x1*x1+c*x1+d;
         x1=x-f/(3*a*x1*x1+2*b*x1+c);
        }
        while (fabs(x-x1)>=1e-10);
        cout<<fixed<<setprecision(3)<<x<<endl;
        return 0;
    }


     

  • 相关阅读:
    Linux下的邮件发送
    Linux下用户和raid练习题
    Linux centos7.5操作系统的安装
    Linux chattr文件锁
    Linux系统下root密码丢失解决方案
    周总结2
    课堂作业1
    开课博客
    阅读3
    作业8
  • 原文地址:https://www.cnblogs.com/2014acm/p/3902542.html
Copyright © 2011-2022 走看看