小红花


私信TA

用户名:Mrlonely

访问量:3749

签 名:

等  级
排  名 9915
经  验 1123
参赛次数 0
文章发表 7
年  龄 0
在职情况 学生
学  校 清华大学
专  业

  自我简介:

#include <iostream>

using namespace std;

struct date{

     int year;

     int month;

     int day;

};

bool Judgeyear(int year){            //判闰年

     bool tag = 0;

     if((year%100 != 0 && year%4 == 0)||year %400 == 0)

          tag = 1;

     return tag;   

}

int Counmonth(int month,int year){            //月份-天数换算

     int sum = 0;

     int a[12] = {31,28,31,30,31,30,31,31,30,31,30,31};

     int b[12] = {31,29,31,30,31,30,31,31,30,31,30,31};

     if(Judgeyear(year) == 1){

         for(int i = 0;i<month-1;i++){

              sum += b[i];

          }

     }

     else{

         for(int i = 0;i<month-1;i++){

              sum +=a[i];

         }

     }

     return sum;

    }

int Plusdata(int day,int month,int year){        //天数总值

     int all = day+Counmonth(month,year);

     return all;

int main(){

    date date;

    cin >> date.year >> date.month >>date.day;

    cout << Plusdata(date.day,date.month,date.year);

    return 0;


 

0.0分

6 人评分

  评论区

#include <iostream>

using namespace std;

struct date{

     int year;

     int month;

     int day;

};

bool Judgeyear(int year){            //判闰年

     bool tag = 0;

     if((year%100 != 0 && year%4 == 0)||year %400 == 0)

          tag = 1;

     return tag;   

}

int Counmonth(int month,int year){            //月份-天数换算

     int sum = 0;

     int a[12] = {31,28,31,30,31,30,31,31,30,31,30,31};

     int b[12] = {31,29,31,30,31,30,31,31,30,31,30,31};

     if(Judgeyear(year) == 1){

         for(int i = 0;i<month-1;i++){

              sum += b[i];

          }

     }

     else{
2021-07-09 10:56:00
  • «
  • 1
  • »