//返回星座 int ChineseCalendar::GetConstellation(int month,int day) { //2012年是闰年 QDate mojie(2012,1,19); //摩羯座终止日10 QDate shuiping(2012,2,18); //水瓶座终止日11 QDate shuangyu(2012,3,20); //双鱼12 QDate baiyang(2012,4,19); //白羊1 QDate jinniu(2012,5,20); //金牛2 QDate shuangzi(2012,6,21); //双子3 QDate juxie(2012,7,22); //巨蟹4 QDate shizi(2012,8,22); //狮子5 QDate chunv(2012,9,22); //处女6 QDate tiancheng(2012,10,23); //天秤7 QDate tianxie(2012,11,22); //天蝎8 QDate sheshou(2012,12,21); //射手9 QDate mday(2012,month,day); if(mday<=mojie) return 10; else if(mday<=shuiping) return 11; else if(mday<=shuangyu) return 12; else if(mday<=baiyang) return 1; else if(mday<=jinniu) return 2; else if(mday<=shuangzi) return 3; else if(mday<=juxie) return 4; else if(mday<=shizi) return 5; else if(mday<=chunv) return 6; else if(mday<=tiancheng) return 7; else if(mday<=tianxie) return 8; else if(mday<=sheshou) return 9; else return 10; }
main() { int dday, dmonth, dyear, dans; int myear, myeard; int mpmon=-1, mpday=-1; printf("\nEnter DD // MM // YYYY : "); scanf("%d%d%d", &dday, &dmonth, &dyear); dans=doy(dyear, dmonth, dday); if(dans > 0) printf("The day of the year is %d\n", dans); printf("\nEnter day of year and the year "); scanf("%d%d", &myeard, &myear); mday(myear, myeard, &mpmon, &mpday); if(mpmon != -1 && mpday != -1) printf("The day %d of the month %d\n", mpday, mpmon); return 0; }