题解 | 四季 季节表

四季

https://www.nowcoder.com/practice/eaf21203b61b4a689987fdc165d00dfc

#include <stdio.h>

int main() {
    int date;
    scanf("%d", &date);
    int month = date % 100;
    // 用数组存储月份对应的季节索引
    int seasonMap[13] = {0,3, 3, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3};
    const char* seasons[4] = {"spring", "summer", "autumn", "winter"};
    printf("%s\n", seasons[seasonMap[month]]);
    return 0;
}

全部评论

相关推荐

评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务