#include "date.h"
  #include "utils.h
  #include <iostream>
  using std::cout;
  using std::endl;
  Date::Date()
  {
      year=1970;
      month=1;
     day=1;
 }
 Date::Date(int y,int m,int d)
 {
     year=y;
     month=m;
     day=d;
 }

 int Date::getYear() const
 {
     return year;
 }
 int Date::getMonth() const
 {
     return month;
 }
 int Date::getDay() const
 {
     return day;
 }
 int Date::dayOfYear()
 {
     int a[12]={31,28,31,30,31,30,31,31,30,31,30,31};
     if( (year % 4 == 0  &&  year % 100 !=0) || (year % 400 == 0) )
     {
         a[1]=29;
     }
     int i,sum=0;
     for(i=0;i<month-1;i++)
     {
         sum=sum+a[i];
     }
     sum=sum+day;
     return sum;

 }
 void Date::display()
 {
     cout<<year<<""<<month<<""<<day<<""<<endl;
 }

期中第一题

相关文章:

  • 2022-12-23
  • 2021-12-28
  • 2022-01-23
  • 2021-08-10
  • 2021-10-02
  • 2021-06-11
  • 2022-12-23
  • 2021-06-22
猜你喜欢
  • 2021-11-05
  • 2021-12-01
  • 2022-12-23
  • 2021-07-07
  • 2022-01-16
  • 2021-08-03
  • 2022-12-23
相关资源
相似解决方案