您的位置:首页 > 其它

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

2014-10-30 09:28 302 查看
#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;
}


字符输入不用&& ||。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐