#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 ",year); } else if (year % 100 != 0) { printf("%d ",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 == ' ') break; s[i] = c; i++; } s[i] = ' '; return 0; }
字符输入不用&& ||。