c语言明明是题库里的答案,为什么运行出来没有结果?

2025-05-13 15:04:44
推荐回答(4个)
回答(1):

#include 
#include 
#include 
double proc(int n)
{
    double y=1.0;
    double j=1.0;
    int i;
    for(i=2;i<=n;i++)
    {
        j=-1*j;
        y+=j/(i*i);
    }
    return(y);
}
int main()
{
    int n=10;
    system("pause");
    printf("\nThe result is %lf\n",proc(n));
}


注意%lf不要写为%If

回答(2):

int main()
{
int n=10;
printf("\nThe result is %lf\n",proc(n));
system("pause");
}

后面一个函数改成这样

回答(3):

有结果啊,例如我运行的结果如下:
The result is 0.817962

回答(4):

%If  是什么东东? 
你是想写 %f  %lf