從題目範例得知1906年為丙午年,直接往前推到1800年
-106分別除10與12再取餘數,把陣列倒著數,可以得知1800年為庚申年。
直接在宣告陣列時把順序排好,輸入n之後直接減1800再取餘數即可拗!
下面有雷,不會再看
----------------------------------------------------------------------------
#include<iostream>
using namespace std;
int main(){
int n;
string array[] = {"庚","辛","壬","癸","甲","乙","丙","丁","戊","己"};
string array2[] = {"申","酉","戌","亥","子","丑","寅","卯","辰","巳","午","未"};
while(cin>>n){
n-=1800;
cout<<array[n%10]<<array2[n%12]<<endl;
}
}