C语言100天练习题【记录本】

C语言经典100题(手把手 编程)

可以在哔哩哔哩找到

已解决的天数:一,二,五,六

下面的都是模模糊糊的

可以学学这些算法,我是算法白痴,但是我不是白痴,可以学!

第三天(未解决)

第四天

cs 复制代码
#include <stdio.h>

// 判断是否为闰年
int isLeapYear(int year) {
    return (year % 4 == 0 && year % 100!= 0) || (year % 400 == 0);
}

int main() {
    int year, month, day;
    int days_in_month[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    int total_days = 0;

    printf("请输入年月日:");
    scanf("%d %d %d", &year, &month, &day);

    // 判断闰年,更新二月天数
    if (isLeapYear(year)) {
        days_in_month[1] = 29;
    }

    // 计算天数
    for (int i = 0; i < month - 1; i++) {
        total_days += days_in_month[i];
    }
    total_days += day;

    printf("这是第%d天\n", total_days);

    return 0;
}
相关推荐
松涛和鸣3 分钟前
41、Linux 网络编程并发模型总结(select / epoll / fork / pthread)
linux·服务器·网络·网络协议·tcp/ip·算法
鹿角片ljp6 分钟前
力扣26.有序数组去重:HashSet vs 双指针法
java·算法
XFF不秃头18 分钟前
力扣刷题笔记-合并区间
c++·笔记·算法·leetcode
巧克力味的桃子1 小时前
学习笔记:查找数组第K小的数(去重排名)
笔记·学习·算法
星云POLOAPI1 小时前
大模型API调用延迟过高?深度解析影响首Token时间的五大因素及优化方案
人工智能·python·算法·ai
88号技师1 小时前
2026年1月一区SCI-波动光学优化算法Wave Optics Optimizer-附Matlab免费代码
开发语言·算法·数学建模·matlab·优化算法
程序员阿鹏1 小时前
如何保证写入Redis的数据不重复
java·开发语言·数据结构·数据库·redis·缓存
JAY_LIN——81 小时前
字符串函数(strncpy/cat/cmp、strstr、strtok、strerror)
c语言·开发语言
明朝百晓生2 小时前
强化学习[chapter8] [page17] Value Function Methods
人工智能·算法
POLITE32 小时前
Leetcode 56.合并区间 JavaScript (Day 6)
算法·leetcode·职场和发展