学c鱼 发表于 2018-10-24 11:40:23

c语言

#include <stdio.h>

int main()
{
        int x , y;
        scanf("%d", &x);
        if(x<1)
        {
                y = x;
        }
        else if((x==1 || x>1) && x<10 )
        {
                y = 2x-1;
        }
        if(x>=10)
        {
                y = 3x-11;
        }
        printf("Y is %d", y);
}


D:\c语言\编程文件\作业5\作业5.c(13) : error C2059: syntax error : 'bad suffix on number'
D:\c语言\编程文件\作业5\作业5.c(13) : error C2146: syntax error : missing ';' before identifier 'x'
D:\c语言\编程文件\作业5\作业5.c(13) : warning C4552: '-' : operator has no effect; expected operator with side-effect
D:\c语言\编程文件\作业5\作业5.c(17) : error C2059: syntax error : 'bad suffix on number'
D:\c语言\编程文件\作业5\作业5.c(17) : error C2146: syntax error : missing ';' before identifier 'x'
D:\c语言\编程文件\作业5\作业5.c(17) : warning C4552: '-' : operator has no effect; expected operator with side-effect
执行 cl.exe 时出错.

这个错误是什么意思啊,看了好久

ba21 发表于 2018-10-24 11:51:11

#include <stdio.h>

int main()
{
      int x , y;
      scanf("%d", &x);
      if(x<1)
      {
                y = x;
      }
      else if((x==1 || x>1) && x<10 )
      {
                y = x-1; // 2x? 是2 * x 还是什么??
      }
      if(x>=10)
      {
                y = x-11;// 3x? 是3 * x 还是什么??
      }
      printf("Y is %d", y);
}

Yo乄 发表于 2018-10-24 12:01:11

ba21 发表于 2018-10-24 11:51


精辟

学c鱼 发表于 2018-10-24 21:17:40

Yo乄 发表于 2018-10-24 12:01
精辟

抱歉,我真的是傻了,这错误{:5_104:}

学c鱼 发表于 2018-10-24 21:18:20

ba21 发表于 2018-10-24 11:51


谢谢谢谢,我真的是傻了,这错误都。。。。

ba21 发表于 2018-10-24 21:38:59

学c鱼 发表于 2018-10-24 21:18
谢谢谢谢,我真的是傻了,这错误都。。。。

请结贴
页: [1]
查看完整版本: c语言