#20490: Java問題


adt107102@gm.ntcu.edu.tw (cwy)


import java.util.Scanner;
public class Ex_004 {
public static void main(String[] args)
{
Scanner year=new Scanner(System.in);
int Y=year.nextInt();
if((Y%4==0 && Y%100!=0)||Y%400==0)
{
System.out.print("閏年");
}
else
{
System.out.print("平年");
}
}

}

我的程式是這樣,但她卻顯示WA(Line1)...?不知道該怎麼改QAQ測試的時候是AC,求解QQ

#20907: Re:Java問題


andreea (andreea)


import java.util.Scanner;
public class Ex_004 {
public static void main(String[] args)
{
Scanner year=new Scanner(System.in);
int Y=year.nextInt();
if((Y%4==0 && Y%100!=0)||Y%400==0)
{
System.out.print("閏年");
}
else
{
System.out.print("平年");
}
}

}

我的程式是這樣,但她卻顯示WA(Line1)...?不知道該怎麼改QAQ測試的時候是AC,求解QQ



他是輸入到eof結束喔,所以你要能夠一直輸入

hint:hasNextInt

應該是這個問題,再試看看吧,加油!