C和C++的double问题
最近在做POJ2109时,看到网上直接用double和pow做的
分别用C++和C都提交了一遍,结果C++能过,C过不了
C++
#include <iostream>
#include <cmath>
#include <math.h>
using namespace std;
const double eps=1e-6;
int main()
{
double n,p;
while(scanf("%lf %lf",&n,&p)!=EOF)
{
double ans=pow(p+eps,1.0/n);
printf("%.0lf\n",ans);
}
return 0;
}
C
#include <stdio.h>
#include <math.h>
const double eps=1e-6;
int main()
{
double n,p,ans;
while(scanf("%lf %lf",&n,&p)!=EOF)
{
ans=pow(p+eps,1.0/n);
printf("%.0lf\n",ans);
}
return 0;
}
深入研究过这些的大神给讲讲这是为什么啊
不胜感激!