数学建模社区-数学中国

标题: 重要的算法C语言实现源代码8 [打印本页]

作者: 青年梦想家    时间: 2015-8-28 16:46
标题: 重要的算法C语言实现源代码8
8.秦九昭算法

C/C++ code
#include <math.h>
float qin(float a[],int n,float x)
{    float r=0;
    int i;
    for(i=n;i>=0;i--)
    r=r*x+a;
    return r;
}
main()
{    float a[50],x,r=0;
    int n,i;
    do
    {    printf("Input frequency:");
        scanf("%d",&n);
    }
    while(n<1);
    printf("Input value:");
    for(i=0;i<=n;i++)
    scanf("%f",&a);
    printf("Input frequency:");
    scanf("%f",&x);
    r=qin(a,n,x);
    printf("Answer:%f",r);
    getch();
}



关于本帖内容欢迎大家踊跃讨论,与在下交流!






欢迎光临 数学建模社区-数学中国 (http://www.madio.net/) Powered by Discuz! X2.5