程序老是在编译时报错
赵雨豪 人气红星 2015-08-08 19:20:25
2757 2 0

#include<stdio.h>

main()

{

  int a;

  printf("请输入一个整数:");

  scanf("%d",a);

  if(a>0);

  {

   printf("%d\n",a);

  }

  else

  {

 printf("%d\n",-a);

  }

}


问题来自: if语句

共 2 个回答

    赵雨豪 人气红星 3205天前

    Compiling...

    二class1.cpp

    C:\Users\adm\Desktop\c语言学习\二class1.cpp(8) : warning C4390: ';' : empty controlled statement found; is this the intent?

    C:\Users\adm\Desktop\c语言学习\二class1.cpp(11) : error C2181: illegal else without matching if

    C:\Users\adm\Desktop\c语言学习\二class1.cpp(15) : warning C4508: 'main' : function should return a value; 'void' return type assumed

    执行 cl.exe 时出错.


    二class1.obj - 1 error(s), 0 warning(s)


    最佳答案

    中二君是个抖S 资深会员 3205天前

    scanf("%d",a);a前面少了&

您还没有登录,所以不能回复该问题
我要回复

  • 0

    点赞

  • 扫一扫分享朋友圈

    二维码

  • 分享

相关问题