μΉ΄ν
κ³ λ¦¬ μμ
[ProjectEuler.net / 5 ] How many Sundays fell on the first of the month during the twentieth century?
ipod apple
2009. 2. 14. 12:45
λ°μν
package com.tistory.honeybox.Euler;
import java.util.Calendar;
public class Euler5
{
public static void main(String [] args)
{
Calendar cal = Calendar.getInstance();
int i,j;
int nCount = 0;
for(i = 1901 ; i <= 2000; i++)
{
for(j = 1 ;j <= 12; j++)
{
cal.clear();
cal.set(i,j,1);
if(cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY)
{
nCount++;
}
}
}
System.out.println(nCount);
}
}
λ°μν