635624913 发表于 2016-3-13 21:44:20

很简单的一个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));
    }
}
我的这个错在哪?为什么不行?

~风介~ 发表于 2016-3-14 00:13:40

说得不清楚再——把测试用例&运行截图发出来?

DAY 发表于 2016-3-14 08:32:39

我在codeBlocks上运行了一下你的代码,,,没有错误啊!

wenlue 发表于 2016-3-14 08:35:11

看着没问题啊

635624913 发表于 2016-3-14 12:20:47

DAY 发表于 2016-3-14 08:32
我在codeBlocks上运行了一下你的代码,,,没有错误啊!

是可以运行,但是结果很有问题啊,图片在后面

635624913 发表于 2016-3-14 12:22:02

不同的运行结果

635624913 发表于 2016-3-14 12:23:03

wenlue 发表于 2016-3-14 08:35
看着没问题啊

是可以运行,但是结果很有问题啊,图片在后面

DAY 发表于 2016-3-16 17:08:26

本帖最后由 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);
    }
}


把这运行你就知道错在那了

atmo 发表于 2016-4-11 08:39:15

&n
页: [1]
查看完整版本: 很简单的一个c语言题,帮忙看一下错在哪