2005 年5月程序员下午试题[7]
试题八(15分,每空3分)[说明]下面程序的功能是计算并输出某年某月的天数。[C++程序]#include<iostream>usingnamespacestd;___(1)___Month(Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec);classDate{public:Date(intyear,Monthm_month){___(2)___=year;if(m_month
试题八(15分,每空3分)
[说明]
下面程序的功能是计算并输出某年某月的天数。
[C++程序]
#include < iostream>
using namespace std;
___(1)___ Month ( Jan , Feb , Mar , Apr , May , Jun , Jul , Aug , Sep , Oct , Nov , Dec ) ;
class Date {
public:
Date ( int year , Month m_month ) {
___(2)___ = year ;
if ( m_month < Jan || m_month > Dec ) month = Jan;
else month = m_month;
} ;
~Date () {} ;
bool IsLeapYear () {
return ( ( year % 4 = = 0&&year % 100 != 0 ) || year %400 = = 0);
};
int CaculateDays () {
switch ( ___(3)___ ) {
case Feb : {
if ( ___(4)___ ) return 29;
else return 28;
}
case Jan : case Mar : case May : case Jul : case Aug : case : Oct:
case Dec : return 31;
case Apr : case Jun : case Sep : case Nov : return 30;
}
};
private :
int year;
Month month;
};
Void main () {
Date day ( 2000 ,Feb );
Cout << day. ___(5)___ ();
}
[答案讨论]
| 软考各科备考资源 | ||
| 资源名称 | 获取方式 | 资源链接 |
| 2026下半年软考各科考试真题汇总 | 免费下载 | 点击获取 |
| 2026年5月高项各科真题汇总 | 免费刷题 | 点击获取 |
| 2026年10月第二批集成基础知识真题 | 免费下载 | 点击获取 |
| 2026年下半年 软件设计师基础知识真题 | 免费下载 | 点击获取 |
| 2026上半年软考各科真题答案汇总 | 免费下载 | 点击获取 |
| 【历年真题】软考各科历年真题答案解析汇总 | 免费刷题 | 点击刷题 |
| 更多软考备考资料请点此查看 | ||
温馨提示:因考试政策、内容不断变化与调整,本网站提供的以上信息仅供参考,如有异议,请考生以权威部门公布的内容为准!

