UJN

UJN,第1张

//
#include
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<>a>>b>>c; 
    xy.assign( a,b,c );
    for( i=0;i<10;i++ ) xy.after();

    xy.out();

    return 0;
}

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/563368.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-02
下一篇 2022-04-02

发表评论

登录后才能评论

评论列表(0条)

保存