d072: 文文的求婚--續集 (Case 版)

題目:http://zerojudge.tw/ShowProblem?problemid=d072
程式碼:

import java.util.Scanner;
public class d072 {

 public static void main(String[] args) {
  // TODO Auto-generated method stub
  Scanner sc = new Scanner(System.in);
  while(sc.hasNext()){
   int n = sc.nextInt();//n行
   int[] year = new int[n];
   for(int i=0;i<n;i++){
    year[i] = sc.nextInt();
   }
   for(int i=0;i<n;i++){
    if((year[i]%4==0 && year[i]%100!=0) || year[i]%400==0){
     System.out.println("Case "+(i+1)+": a leap year");
    }else{
     System.out.println("Case "+(i+1)+": a normal year");
    }
   }
  }

 }

}

留言

熱門文章