程序代码:
#include "stdio.h" enum start { Capricorn,//摩羯 bottle,//水瓶 Pisces,//双鱼 Aries,//白羊 Taurus,//金牛 Gemini,//双子 Cancer,//巨蟹 lion,//狮子 Virgo,//处女 Libra,//天枰 scorpio,//天蝎 sagittarius//射手 }; enum mon { January = 1, February, March, April, May, June, July, August, September, October, November, December }; int getstar(int mon, int day) { switch (mon) { case January: if (day >= 20) { return bottle; } else { return Capricorn; } case February: if (day >= 19) { return Pisces; } else { return bottle; } case March: if (day >= 21) { return Aries; } else { return Pisces; } case April: if (day >= 20) { return Taurus; } else { return Aries; } case May: if (day >= 21) { return Gemini; } else { return Taurus; } case June: if (day >= 22) { return Cancer; } else { return Gemini; } case July: if (day >= 23) { return lion; } else { return Cancer; } case August: if (day >= 23) { return Virgo; } else { return lion; } case September: if (day >= 23) { return Libra; } else { return Virgo; } case October: if (day >= 24) { return scorpio; } else { return Libra; } case November: if (day >= 23) { return sagittarius; } else { return scorpio; } case December: if (day >= 22) { return Capricorn; } else { return sagittarius; } default: return Capricorn; } } int main() { int a[12][12] = { {88,74,77,43,97,70,80,59,92,51,85,64},//摩羯--0 { 69,87,60,72,41,91,58,78,64,96,51,82 },//水瓶--1 { 100,100,100,100,100,100,100,100,100,100,100,100 },//双鱼--不全 { 58,88,79,90,75,82,47,94,65,85,70,99 },//白羊 { 93,66,81,68,88,72,75,25,97,57,78,61 },//金牛 { 64,99,48,79,76,89,71,81,57,93,69,86 },//双子 { 87,74,97,52,82,78,89,61,84,66,92,70 },//巨蟹 { 77,84,62,97,56,79,69,87,72,81,45,92 },//狮子 { 95,55,84,61,91,76,88,66,89,49,81,72 },//处女 { 47,95,64,85,74,98,58,88,77,90,71,80 },//天枰 { 76,57,92,60,80,68,97,65,84,73,87,47 },//天蝎 { 75,78,44,92,70,81,65,98,58,86,68,89 },//射手 }; char star[12][12] = {"摩羯","水瓶","双鱼","白羊","金牛","双子","巨蟹","狮子","处女","天枰","天蝎","射手"}; int man_mon, man_day, woman_mon, woman_day; int man_star, woman_star; printf("请输入男生生日(格式:月.日):"); scanf("%d.%d",&man_mon,&man_day); printf("请输入女生生日(格式:月.日):"); scanf("%d.%d", &woman_mon, &woman_day); man_star = getstar(man_mon, man_day); woman_star = getstar(woman_mon, woman_day); printf("男生的星座是%s,女生的星座是%s,\n", star[man_star], star[woman_star]); printf("他们的缘分是%d%%.\n", a[woman_star][man_star]); }