问题 填空题

[说明]
设计一个日期类Date,包括年、月、日等私有数据成员。要求实现日期的基本运算,如某日期加上天数、某日期减去天数、两日期相差的天数等。
在Date类中设计如下重载运算符函数。
Date operator+(int days):返回某日期加上天数得到的日期。
Date operator-(int days):返回某日期减去天数得到的日期。
int operator-(Date &b):返回两日期相差的天数。
[C++程序]
#include<iostream. h>
int day_tab[2][12]=31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
31, 29, 31,30, 31, 30, 31, 31,30,31,30,31;
//day_tab二维数组存放各月天数,第一行对应非闰年,第二行对应闰年
class Date

int year,month,day;//年,月,日
int leap (int); //判断是否为闰年
int dton (Date&);
Date ntod (int);
Public:
Date()
Date(int y,int mint d)year=y;month=m;day=d;
void setday (intd) day=d;
void setmonth (int m)month=m;
void setyear(int y)year=y;
int getday()return day;
int getmonth()return month;
int getyear() return year;
Date operator+(int days) //+运算符重载函数

static Date date;
int number= (1) ;
date=ntod (number);
return date;

Date operator-(int days) //-运算符重载函数

statis Date date;
int number= (2) ;
number-=days;
date=ntod (number);
return date;

int operator-(Date &b) //-运算符重载函数

int days= (3) ;
return days;

void disp()

cout<<year<<"."<<month<<","<<day<<endl;

;
int Date::leap (int year)
if( (4) ) //是闰年
return 1; //不是闰年
else
return 0;

int Date::dton (Date &d) //求从公元0年0月0日到d日期的天数

int y,m,days=0;
for (y=1;y<=d.year;y++)
if( (5) )days+=366; //闰年时加366天
else days+=365; //非闰年时加365天
for (m=0;m<d.mont.h-1;m++)
if (leap (d.year)
days+=day_tab [1] [m];
else
days+=day__tab [0][m];
days+=d.day;
return days;
Date Date::ntod (int n) //将从公元0年0月0日的天数转换成日期

int y=1,m=1,d,rest=n,1p;
while (1)
if (leap (y))
if (rest<-366)break;
else rest-=366;
else //非闰年
if (rest=365)break;
else rest-=365;
y++;

y--;
1p=leap (y);
while (1)

if (1p) //闰年
if (rest>day_tab [1][m-1])rest-=day_tab [1] [m-1];
else break;
else //非闰年
if(rest>day_tab[0] [m-1])rest-=day_tab[0][m-1];
else break;
m++:

d=rest;
return Date (y; m, d);

void main()

Date now(2003, 10,1),then (2005,6,5);
cout<<"now:"; now. disp();
cout<<"then:"; then .disp();
cout<<"相差天数:"<<(then-now)<<endl;
Date d1=now+1000,d2=now-1000;
cout<<"now+1000:"; d1. disp();
cout<<"now-1000:"; d2. disp();

答案

参考答案:year%4==0&&year%100!=0||year%400==0

完形填空
I agree with the saying that some people “see old memories as a chance to deal with the past and unite past and present.” Many people are so ___1___ by things that happened in their past that they are not able to focus on the ___2___ . For example, in the book Ceremony, the main character, Tayo, cannot concentrate on the present because he can’t forget his troubled childhood and ___3___ continues to relive things that happened during that time.
However, past memories can help people to ___4___ in the present. A ___5___ example of people learning from the past would be the Marshall Plan. After the ___6___ of World War II there were many war-torn countries around the world in need of ___7___ assistance to help rebuild their countries, and the United States would have to be the one to ___8___ that assistance. Many American politicians thought it was ___9___ for the US government to spend money abroad on countries that would not be able to repay it for a long time. However, George Marshall, a former US general, remembered how the exact same ___10___ of "why should we spend money on war-torn nations that really owe us reparations (赔款)?" had been used after World War I towards Germany. The ___11___ of assistance towards Germany after World War I had caused a gigantic economic depression in Germany that had made the Mark (German money) virtually ___12___ . The German people became so desperate that they started ___13___ an extreme German nationalist named Adolf Hitler, who eventually started World War II. Marshall knew that if the US did not ___14___ war-torn Germany and, especially, Japan, we could ___15___ have a World War III on our hands.
小题1:
A.shocked B.troubled C.punished D.annoyed
小题2:
A.memory B.situation C.present D.future
小题3:
A.constantlyB.innocently C.ridiculously D.rarely
小题4:
A.forget B.recover C.enjoy D.compare
小题5:
A.personal B.scientific C.historical D.commercial
小题6:
A.conclusionB.decision C.invasion D.extension
小题7:
A.medical B.political C.economic D.lawful
小题8:
A.need B.provide C.find D.prevent
小题9:
A.reasonableB.necessary C.difficult D.foolish
小题10:
A.statementB.argument C.suggestion D.introduction
小题11:
A.intensionB.request C.influence D.lack
小题12:
A.hopeless B.worthless C.worldwide D.valuable
小题13:
A.refusing B.employing C.supporting D.charging
小题14:
A.stop B.warn C.resist D.help
小题15:
A.similarlyB.simplyC.regularly D.unlikely
问答题