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

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

可以在哔哩哔哩找到

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

下面的都是模模糊糊的

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

第三天(未解决)

第四天

#include 

// 判断是否为闰年
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;
}

你可能感兴趣的:(c语言,算法,数据结构)