很简单的一个c语言题,帮忙看一下错在哪
先是正确的#include<stdio.h>#include<math.h>
int main()
{
int x,y,z;
float n;
while(~scanf("%f",&n))
{
x=ceil(n);
y=floor(n);
z=round(n);
printf("%d %d %d\n",x,y,z);
}
}
然后是我的
#include<stdio.h>
#include<math.h>
int main()
{
float n;
while(~scanf("%f",&n))
{
printf("%d %d %d\n",ceil(n),floor(n),round(n));
}
}
我的这个错在哪?为什么不行? 说得不清楚再——把测试用例&运行截图发出来? 我在codeBlocks上运行了一下你的代码,,,没有错误啊! 看着没问题啊 DAY 发表于 2016-3-14 08:32
我在codeBlocks上运行了一下你的代码,,,没有错误啊!
是可以运行,但是结果很有问题啊,图片在后面 不同的运行结果 wenlue 发表于 2016-3-14 08:35
看着没问题啊
是可以运行,但是结果很有问题啊,图片在后面 本帖最后由 DAY 于 2016-3-16 17:09 编辑
#include<stdio.h>
#include<math.h>
int main()
{
float n;
while(~scanf("%f",&n))
{
printf("n=%d ceil(n)=%d n=%d floor(n)=%dn=%d round(n)=%d n=%d\n",n,ceil(n),n,floor(n),n,round(n),n);
}
}
把这运行你就知道错在那了 &n
页:
[1]