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;
}
相关推荐
wadesir4 小时前
Rust中的条件变量详解(使用Condvar的wait方法实现线程同步)
开发语言·算法·rust
yugi9878384 小时前
基于MATLAB实现协同过滤电影推荐系统
算法·matlab
TimberWill4 小时前
哈希-02-最长连续序列
算法·leetcode·排序算法
Morwit4 小时前
【力扣hot100】64. 最小路径和
c++·算法·leetcode
leoufung4 小时前
LeetCode 373. Find K Pairs with Smallest Sums:从暴力到堆优化的完整思路与踩坑
java·算法·leetcode
wifi chicken5 小时前
数组遍历求值,行遍历和列遍历谁更快
c语言·数据结构·算法
qingyun9895 小时前
深度优先遍历:JavaScript递归查找树形数据结构中的节点标签
前端·javascript·数据结构
胡楚昊5 小时前
NSSCTF动调题包通关
开发语言·javascript·算法
Gold_Dino6 小时前
agc011_e 题解
算法
bubiyoushang8886 小时前
基于蚁群算法的直流电机PID参数整定 MATLAB 实现
数据结构·算法·matlab