题解 | #四季#
四季
http://www.nowcoder.com/practice/eaf21203b61b4a689987fdc165d00dfc
#include <stdio.h>
int main()
{
int a;
int b = 0;
int c = 100000;
scanf("%d", &a);
while (b < 4)
{
a %= c;
c /= 10;
b++;
}
//利用取余去掉年份,留下月份,然后判断月份属于哪个季节
if (a >= 3 && a <= 5)
{
printf("spring\n");
}
else if (a >= 6 && a <= 8)
{
printf("summer\n");
}
else if (a >= 9 && a <= 11)
{
printf("autumn\n");
}
else if (a == 12 || a == 1 || a == 2)
{
printf("winter\n");
}
return 0;
}