sunnyrubik 发表于 2018-10-21 20:15:08

运行时出现[Error] invalid suffix 'n' on integer constant

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main()
{
        double pi;
        int n;
        printf("%4s%10s","n","pi");
        for(n=1,pi=0;n<=10;++n)
        {
                pi=4+pow(-1,n)*(4/(2n-1));
                printf("%4d%10.5f",n,pi);
        }
        system("pause");
        return 0;
}


请教一下大家在11行的错误什么原因呢?
万分感谢

塔利班 发表于 2018-10-21 20:15:09

2*n-1
页: [1]
查看完整版本: 运行时出现[Error] invalid suffix 'n' on integer constant