Content

民國元年 ( 1912 ) 是鼠年。

給定若干個民國年份   -100 ~ 107

請輸出該年生肖為何。

Input
 
Output
 
Sample Input #1
1
107
Sample Output #1
鼠
狗

 

from sys import stdin
post="鼠牛虎兔龍蛇馬羊猴雞狗豬"
pri="豬狗雞猴羊馬蛇龍兔虎牛鼠"

for s in stdin:
    n=int(s)#輸入進的整數
    if (n>0):#輸入得數為正
        n=(n-1)%12 #數字-1剛好對應到索引,因為鼠年為數字1
        print(post[n])
    else:#輸入為負
        n=(abs(n)-1)%12 #數字-1剛好對應到索引
        print(pri[n])
文章標籤
全站熱搜
創作者介紹
創作者 趴趴熊日常 的頭像
趴趴熊日常

資工趴趴熊的小天地

趴趴熊日常 發表在 痞客邦 留言(0) 人氣(406)