#include"iostream" #include"iomanip" using namespace std; class Date { int year, month, day; public: void set(int x, int y, int z) { year = x; month = y; day = z; } bool isleapyear(); void print() { cout << setw(4) << year << '-' << setw(2) << '-' << month << '-' << setw(2) << day << endl; }
};
inline bool Date::isleapyear() { return(year % 4 == 0 && year % 100 != 0) || (year % 400 == 0); }
int main() { Date d; d.set(2018, 5, 5); if (d.isleapyear()) d.print(); else cout << "爷爷不是闰年" << endl; system("pause"); return 0;
}
|