供参考
#include <stdio.h>
typedef struct
{
int year, month, day;
} DATE;
typedef struct
{
char name[10];
int sM;
int sD;
int eM;
int eD;
} STARTS;
STARTS starts[] = {{""}, {"水瓶座", 1, 20, 2, 18}, {"双鱼座", 2, 19, 3, 20}, {"白羊座", 3, 21, 4, 19}, {"金牛座", 4, 20, 5, 20}, {"双子座", 5, 21, 6, 21}, {"巨蟹座", 6, 22, 7, 22}, {"狮子座", 7, 23, 8, 22}, {"处女座", 8, 23, 9, 22}, {"天秤座", 9, 23, 10, 23}, {"天蝎座", 10, 24, 11, 22}, {"射手座", 11, 23, 12, 21}, {"摩羯座", 12, 22, 1, 19}};
int month[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int Err(int y, int m, int d)
{
int err = 0;
int leap = (y % 400 == 0 || (y % 4 == 0 && y % 100 != 0));
if (y < 1 || m > 12 || m < 1 || d < 1)
err = 1;
if (m != 2 && d > month[m])
err = 1;
if (m == 2)
{
if (leap && d > month[m] + 1)
err = 1;
if (!leap && d > month[m])
err = 1;
}
return err;
}
void con(DATE date)
{
int m = date.month;
if (date.day < starts[m].sD)
{
if (m == 1)
m = 12;
else
m--;
}
printf("%s\n", starts[m].name);
}
int main()
{
int n;
scanf("%d", &n);
DATE *date = (DATE *)malloc(n * sizeof(DATE));
for (int i = 0; i < n; i++)
{
scanf("%d%d%d", &date[i].year, &date[i].month, &date[i].day);
}
for (int i = 0; i < n; i++)
{
if (Err(date[i].year, date[i].month, date[i].day))
{
printf("雅典娜\n");
continue;
}
con(date[i]);
}
system("pause");
return 0;
}