输入一个年输出其天干地支纪年法的表达式
#include <iostream> #include <cmath> using namespace std; char *day_name1(int x) { static char *name[20]={"Gui","Jia", "Yi", "Bing", "Ding", "Wu", "Ji", "Geng", "Xin", "Ren", "Gui"}; return (name[x]); } char *day_name2(int y) { static char *name[20]={"Hai","Zi", "Chou", "Yin", "Mao", "Chen", "Si", "Wu", "Wei", "Shen", "You", "Xu", "Hai"}; return (name[y]); } int main() { int m; cin>>m; while(m--) { int year,t,d; char *day_name1(int x); char *day_name2(int y); cin>>year; t=(year-3)%10; d=(year-3)%12; cout<<day_name1(t)<<day_name2(d)<<endl; } return 0; }
请dalao不吝赐教。