f0808.cpp
资源名称:c.rar [点击查看]
上传用户:puke2000
上传日期:2022-07-25
资源大小:912k
文件大小:1k
源码类别:
C#编程
开发平台:
Visual C++
- //=====================================
- // f0808.cpp
- // bad design: public data members
- //=====================================
- #include<iostream>
- #include<iomanip>
- using namespace std;
- //-------------------------------------
- class Date{
- public:
- int year, month, day;
- };//-----------------------------------
- void print(Date);
- bool isLeapYear(Date d);
- //-------------------------------------
- int main(){
- Date d;
- d.year = 2000;
- d.month = 12;
- d.day = 6;
- if(isLeapYear(d))
- print(d);
- }//------------------------------------
- void print(Date s){
- cout<<setfill('0');
- cout<<setw(4)<<s.year<<'-'<<setw(2)<<s.month<<'-'<<setw(2)<<s.day<<'n';
- cout<<setfill(' ');
- }//------------------------------------
- bool isLeapYear(Date d){
- return (d.year % 4==0 && d.year % 100!=0)||(d.year % 400==0);
- }//====================================