Created
March 1, 2011 19:35
-
-
Save hanachin/849727 to your computer and use it in GitHub Desktop.
苦C 練習問題11 説明ちゃんとよんでなかった。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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