《c程序设计语言》读书笔记--闰年和字符输入不用 && ||

#include <stdio.h>
#include <string.h>

#define sta 1500
#define Num 1600

int main()
{
    int year;

    for(year = sta;year < Num + 1;year++)
        if(year % 4 == 0)
        {
             if(year % 400 == 0)
             {
                 printf("%d \n",year);
             }
              else if (year % 100 != 0)
             {
                printf("%d \n",year);
             }
        }

    return 0;
}

闰年判断。




#include <stdio.h>
#include <string.h>

#define Num 1600

int main()
{
    int c,i = 0;
    char s[Num];

    while(i < (Num - 1))
    {
        c = getchar();

        if(c == EOF)
            break;
        else if(c == '\n')
            break;

        s[i] = c;
        i++;
    }
    s[i] = '\0';

    return 0;
}

字符输入不用&& ||。


posted @ 2014-10-30 09:28  司空格子Ored  阅读(327)  评论(0编辑  收藏  举报