#include<bits/stdc++.h>
using namespace std;
int main()
{
string n[]={"鼠","牛","虎","兔","龍","蛇","馬","羊","猴","雞","狗","豬" };
int a,h;
while(cin>>a)
{
h=(a<12&&a>0) ?a:a%12;
h=(h>=0) ? ((h==0) ? ((a<0) ? h--:h=11):h-1):((h==-12) ? h=1:h+12);
cout<<n[h]<<endl;
}
}
我的是:
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv){
string a[]={"鼠","牛","虎","兔","龍","蛇","馬","羊","猴","雞","狗","豬" };
int c;
while(cin>>c)
cout<<a[(c+119+(c<0))%12]<<endl;
}