Problem Description

珊珊終於學成歸國了,文文的考驗時刻也到了。走出了迎客大廳,珊珊問:「What type of year was I born in?」文文很有自信的回答:「閏年!」可是珊珊卻說:「No, It was a LEAP YEAR!」看來文文要娶到珊珊,還得先把英文練一練。

The Input

輸入的第一行有一個整數 n。接下來的 n 行每行有一個正整數 y,代表珊珊生日的西元年份。

The Output

對於所輸入的每個 y,要各別輸出一行。每一行由「Case i: 」開頭,其中的 i 代表第 i 筆測試資料,若 y 是閏年,請於該行接著輸出「a leap year」,否則請輸出「a normal year」。請參閱範例輸出。

Sample Input

4
1992
1993
1900
2000

Sample Output

Case 1: a leap year
Case 2: a normal year
Case 3: a normal year
Case 4: a leap year

-----* Problem from【ZeroJudge, an Online Judge System For Beginners

My Answer

 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
  #include<iostream>
using namespace std;
int main(void)
{
  int n;
  while(cin>>n){
    int y[n];
    for(int i=0; i<n; ++i){
      cin>>y[i];
    }
    for(int i=0; i<n; ++i){
      if(y[i]%4==0 && y[i]%100!=0 || y[i]%400==0)
        cout<<"Case "<<i+1<<": a leap year"<<endl;
      else cout<<"Case "<<i+1<<": a normal year"<<endl;
    }
  }
  return 0;
}
 

 


arrow
arrow
    全站熱搜

    兔老大 發表在 痞客邦 留言(0) 人氣()