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;
}
相关推荐
core5121 小时前
CatBoost:自带“翻译官”的算法专家
算法·boost·catboost
YGGP1 小时前
【Golang】LeetCode 139. 单词拆分
算法·leetcode
wuguan_1 小时前
C#递推算法
算法·c#·递推算法
_OP_CHEN2 小时前
【C++数据结构进阶】从 Redis 底层到手写实现!跳表(Skiplist)全解析:手把手带你吃透 O (logN) 查找的神级结构!
数据结构·数据库·c++·redis·面试·力扣·跳表
多米Domi0112 小时前
0x3f第14天 最长公共子序列
算法·深度优先
名誉寒冰2 小时前
Redis 常用数据结构与实战避坑指南
数据结构·数据库·redis
spssau2 小时前
正交试验设计全解析:从正交表生成到极差与方差分析
数据库·算法·机器学习
minhuan2 小时前
大模型应用:不减性能只减负担:大模型稀疏化技术全景与实践.36
大数据·人工智能·算法
爱学大树锯2 小时前
592 · 查找和替换模式
算法
爱学大树锯2 小时前
775 · 回文对
算法