问答详情
源自:4-2 分支结构之简单if-else语句

闰年这一节是不是有问题?

#include <stdio.h>
int main() 
{
    int year = 2014; //今年是2014年
    //补全一下代码
    if(=)
    {
        printf("%s\n",今年是闰年);
    }
    else
    {
        printf("%s\n",今年是平年);
    }
    return 0;
}

试了很多次,怎么提交都是正确的提交之后就是类似与这样

<pre>hello.c: In function 'main': hello.c:6:8: error: expected expression before '=' token if(=) ^ hello.c:8:9: error: stray '\344' in program printf("%s\n",今年是闰年); ^ hello.c:8:9: error: stray '\273' in program hello.c:8:9: error: stray '\212' in program hello.c:8:9: error: stray '\345' in program hello.c:8:9: error: stray '\271' in program hello.c:8:9: error: stray '\264' in program hello.c:8:9: error: stray '\346' in program hello.c:8:9: error: stray '\230' in program hello.c:8:9: error: stray '\257' in program hello.c:8:9: error: stray '\351' in program hello.c:8:9: error: stray '\227' in program hello.c:8:9: error: stray '\260' in program hello.c:8:9: error: stray '\345' in program hello.c:8:9: error: stray '\271' in program hello.c:8:9: error: stray '\264' in program hello.c:12:9: error: stray '\344' in program printf("%s\n",今年是平年); ^ hello.c:12:9: error: stray '\273' in program hello.c:12:9: error: stray '\212' in program hello.c:12:9: error: stray '\345' in program

 一部分

怎么回事?

提问者:边防连 2017-09-03 10:23

个回答

  • qq_A丶小茌网络_0
    2017-09-03 15:33:23

    6行应该是 if(year%4==0)

  • hourouer
    2017-09-03 14:03:13

    第6行应该是 if(year%4==0)