Created
July 11, 2012 10:53
-
-
Save skRyo/3089637 to your computer and use it in GitHub Desktop.
グレゴリオ的な
This file contains hidden or 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
/* | |
* 西暦年が4で割り切れる年は閏年 | |
ただし、西暦年が100で割り切れる年は平年 | |
ただし、西暦年が400で割り切れる年は閏年 | |
* | |
*/ | |
public class gregoriano { | |
public static void main(String[] args) { | |
int x = 1000; | |
for ( int i = 1; i <= x; i++ ){ | |
if ( i%4==0 ){ | |
if ( i%400==0 || i%100!=0 ){ | |
System.out.println(i + " 閏年みたいだよ"); | |
}else{ | |
System.out.println(i); | |
} | |
}else{ | |
System.out.println(i); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
あ、色々抜けてた。しかもまだ冗長だな。
if ((i % 4 == 0) && (i % 100 != 0) || (i % 400 == 0))
でFA。