//
#include<bits/stdc++.h>
using namespace std;
#define is_leap(y) ( ( y%4==0 && y%100 ) || ( y%400==0 && y%3200 ) || ( y%172800==0 ) )
// 1 2 3 4 5 6 7 8 9 10 11 12
const int month_day[]={ 0,31,28,31,30,31,30,31,31,30,31,30,31 };
class date
{
private:
int day,month,year;
public:
date( int a,int b,int c ):day(a),month(b),year(c) {}
void assign( int a,int b,int c ) { day=a; month=b; year=c; }
void after()
{
int judge=month_day[ month ];
if( is_leap(year) && judge==28 ) judge++;
day++;
if( day>judge ) { month++; day=1; }
if( month>12 ) { year++; month=1; }
}
void out() { cout<<month<<"/"<<day<<"/"<<year<<endl; }
};
int main()
{
date xy( 10,1,2013 );
int i,a,b,c;
xy.out();
cin>>a>>b>>c;
xy.assign( a,b,c );
for( i=0;i<10;i++ ) xy.after();
xy.out();
return 0;
}
UJN_C++_1383 [Objetos y clases de C++] Clases y objetos de fecha
Supongo que te gusta
Origin blog.csdn.net/qq_63173957/article/details/123887388
Recomendado
Clasificación