上海网站建设哪,lnmp怎么做网站,网站办公室文化建设,龙象建设集团有限公司网站一、程序改错题使用VC6.0打开考生文件夹下的源程序文件1.cpp#xff0c;该程序运行时有错#xff0c;请改正其中的错误#xff0c;使程序正常运行#xff0c;输出的结果为Constructor#xff0c;i0#xff0c;Destructor注意#xff1a;错误的语句在//******error******…一、程序改错题使用VC6.0打开考生文件夹下的源程序文件1.cpp该程序运行时有错请改正其中的错误使程序正常运行输出的结果为Constructori0Destructor注意错误的语句在//******error******的下面修改该语句即可。试题程序#include(iostream.h)classTC{inti;publicTC();voiddisplay();TC();};//******error******TCTC(){couti0;)//******error******TCdisplay(){tout}//******error******TCTC(){COUI}voidmain(){TCa;a.display();}答案(1)应改为“TCTC()”。(2)应改为“voidTCdisplay()”。(3)应改为“TCTC()”。二、简单应用题使用VC6.0打开考生文件夹下的源程序文件2.cpp。请完成函数fun(char*strcharch)的定义本函数采用二分法在已按字母次序从小到大排序的字符数组str中查找字符ch若ch在数组中函数返回字符ch在数组中的下标否则返回1。二分法查找的思想是初始查找区间的下界为0上界为len-1查找区间的中部后k(下界上界)/2;若list[k]等于ch查找成功;若list[k]ch则新的查找区间的下界不变上界改为k-1;否则新的查找区间的下界改为k1上界不变。在新区间内继续用二分法查找。注意请勿改动主函数main与其他函数中的任何内容仅在函数fun的花括号中填入所编写的若干语句。试题程序#include(iostream.hintfun(char*strcharch){}voidmain(){charstr[]{abCdef9hijk);charch;coutcinch;coutreturn;}答案intlow0;//初始查找区间的下界inthigh;intk;for(high0;str[high]!0;high)//求字符串长度while(10w{k(lowhigh)/2;if(str[k]ch)returnk;elseif(str[k]ch)highk-lelselowk1}if(str[low]ch)returnlow;return-1三、综合应用题使用VC6.0打开考生文件夹下的源程序文件3.cpp其中定义了用于表示日期的类Date但类Date的定义并不完整按要求完成下列操作将类的定义补充完整。(1)定义私有成员变量year、month、day。分别表示年、月、日类型为int。请在注释1后添加适当的语句。(2)完成构造函数分别给year、month、day赋值请在注释2后添加适当的语句。(3)完成重载符号“十”的定义请在注释3后添加适当的语句。(4)完成print打印函数输出到屏幕和文件的格式相同请在注释4后添加适当的语句。注意仅在函数指定位置添加语句请勿改动主函数main与其他函数中的任何内容。程序正常运行输出的结果为2008年11月813。试题程序#include(iostream.h)#include(fstream)#include(iomanip)#includeusingnamespacestd;voidWriteFile(intc){ofstreamout1;out1.open(3.txtios_baseapp);out1out1.close();}voidWriteFile(char*str){ofstreamoutl;out1.open(3.txtios_baseapp);out1out1.close();}voidClearFile(){ofstreamout1;out1.open(3.txt);out1.close();}classDate{publicDate(intyintmintd){//********1********}voidprint();//********2********{monthm;intimonth/12intjmonth%12;if(j0){year(i-1);month12;}else{yearimonthj;}return*this;}private//********3********};voidDateprint(){//********4********WriteFile(year)WriteFile(年);WriteFile(month);WriteFile(月);WriteFile(day);WriteFile(日);}intmain(){ClearFile();DateOly_day(200888);Olyday3Oly_day.print();return0;}答案(1)应添加“yeary;monthm;dayd;”。(2)应添加“Dateoperator(intm)”。(3)应添加“intyearmonthday;”。(4)应添加“cout