Skip to content

Instantly share code, notes, and snippets.

@hanachin
Created March 1, 2011 19:35
Show Gist options
  • Save hanachin/849727 to your computer and use it in GitHub Desktop.
Save hanachin/849727 to your computer and use it in GitHub Desktop.
苦C 練習問題11 説明ちゃんとよんでなかった。
include <stdio.h>
int olympics(int year);
int main(void) {
int year;
scanf("%d", &year);
if (olympics(year)) {
printf("オリンピックが開かれます。\n");
} else {
printf("オリンピックが開かれません。\n");
}
return 0;
}
int olympics(int year) {
if (year < 1896) {
return 0;
}
if (1916 == year || 1940 == year || 1944 == year) {
return 0;
}
if (1994 <= year && year % 4 == 2) {
return 1;
}
return year % 4 == 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment