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;
}
相关推荐
qq_401700412 小时前
嵌入式用Unix时间的优势及其C语言转换
服务器·c语言·unix
mit6.8244 小时前
bfs|栈
算法
CoderYanger5 小时前
优选算法-栈:67.基本计算器Ⅱ
java·开发语言·算法·leetcode·职场和发展·1024程序员节
jllllyuz5 小时前
Matlab实现基于Matrix Pencil算法实现声源信号角度和时间估计
开发语言·算法·matlab
稚辉君.MCA_P8_Java6 小时前
DeepSeek 插入排序
linux·后端·算法·架构·排序算法
多多*6 小时前
Java复习 操作系统原理 计算机网络相关 2025年11月23日
java·开发语言·网络·算法·spring·microsoft·maven
.YM.Z7 小时前
【数据结构】:排序(一)
数据结构·算法·排序算法
Chat_zhanggong3457 小时前
K4A8G165WC-BITD产品推荐
人工智能·嵌入式硬件·算法
百***48077 小时前
【Golang】slice切片
开发语言·算法·golang
墨染点香7 小时前
LeetCode 刷题【172. 阶乘后的零】
算法·leetcode·职场和发展