无心小男


私信TA

用户名:uq_50395433181

访问量:1638

签 名:

等  级
排  名 1342
经  验 2867
参赛次数 0
文章发表 4
年  龄 0
在职情况 学生
学  校
专  业

  自我简介:

TA的其他文章

注意事项:

    注意闰年和平年的区别,闰年二月有29天,平年的二月有28天
参考代码:

#include<iostream>
//#include<bits/stdc++.h>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<cstdio>
using namespace std;

bool cmp(int a, int b) {
    return a > b;
}

int main() {
    int sum = 0;
    int year, month, day;
    cin >> year >> month >> day;
    int month1[12] = { 31,29,31,30,31,30,31,31,30,31,30,31 };
    int month2[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };
    if ((year % 4 == 0 && year % 100 != 0) || (year % 400) == 0) {
        for (int i = 0; i < month - 1; i++) {
            sum += month1[i];
        }
    }
    else {
        for (int i = 0; i < month - 1; i++) {
            sum += month2[i];
        }
    }
    sum += day;
    cout << sum;
    return 0;
}


 

0.0分

2 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区