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;
}
相关推荐
Swift社区几秒前
LeetCode 377 组合总和 Ⅳ
算法·leetcode·职场和发展
漫随流水几秒前
leetcode算法(404.左叶子之和)
数据结构·算法·leetcode·二叉树
wanghu2024几秒前
ABC440_D题_题解
算法
Tisfy几秒前
LeetCode 2975.移除栅栏得到的正方形田地的最大面积:暴力枚举所有可能宽度
算法·leetcode·题解·模拟·暴力
啊阿狸不会拉杆1 分钟前
《数字图像处理》第 1 章 绪论
图像处理·人工智能·算法·计算机视觉·数字图像处理
Loo国昌2 分钟前
【LangChain1.0】第二篇 快速上手实战
网络·人工智能·后端·算法·microsoft·语言模型
BHXDML3 分钟前
第二章:决策树与集成算法
算法·决策树·机器学习
橘颂TA4 分钟前
【剑斩OFFER】算法的暴力美学——力扣 692 题:前 K 个高频单词
网络·算法·leetcode·哈希算法·结构与算法
练习时长一年4 分钟前
LeetCode热题100(乘积最大子序列)
数据结构·算法·leetcode
仰泳的熊猫5 分钟前
题目1109:Hanoi双塔问题
数据结构·c++·算法·蓝桥杯