为什么有的程序在Gode::Blocks 10.05运行结果不对,在VC++6.0运行却是对的?比如
#include<stdio.h>intmain(){intn,a,b,i,c;floatsum;scanf("%d",&n);for(a=1;a<=n;a++){sum...
#include <stdio.h>
int main()
{
int n,a,b,i,c;
float sum;
scanf("%d",&n);
for(a=1;a<=n;a++)
{ sum=0;
scanf("%d",&b);
for(i=1;i<=b;i++)
{
if(i%2==0)
sum=sum+(-1)/i;
else
sum=sum+1/i;
}
printf("%.2f\n",sum);
}
return 0;
} 展开
int main()
{
int n,a,b,i,c;
float sum;
scanf("%d",&n);
for(a=1;a<=n;a++)
{ sum=0;
scanf("%d",&b);
for(i=1;i<=b;i++)
{
if(i%2==0)
sum=sum+(-1)/i;
else
sum=sum+1/i;
}
printf("%.2f\n",sum);
}
return 0;
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询