353500315 发表于 2020-11-25 17:50:17

c语言问题

#include <stdio.h>
int main(void)
{
    int cows,legs;
    printf("How many cow legs did you count?\n");
    scanf("%d",&legs);
    cows = legs / 4;
    printf("That implies there are %d cows.\n, cows");

return 0;
}



对于这个程序,比如说我输入了数字8,但是得出来的结果却是11。这是怎么回事。

jackz007 发表于 2020-11-25 18:17:56

本帖最后由 jackz007 于 2020-11-25 18:20 编辑

      引号写错了位置
      printf("That implies there are %d cows.\n, cows");
      改成下面这样
      printf("That implies there are %d cows.\n", cows);

sky2020 发表于 2020-12-3 14:47:17

jackz007 发表于 2020-11-25 18:17
引号写错了位置
      printf("That implies there are %d cows.\n, cows");
      改成下面 ...


页: [1]
查看完整版本: c语言问题