for(j=0,len=0;
(2);j++){
if((3)&&len
len=b[j];
}
}
Printf("len:
%d\n",maxL(b,n));printf("\n");
}
【问题1】(8分)
根据说明和C代码,填充C代码中的空
(1)〜(4)。
【问题2】(4分)
根据说明和C代码,算法采用了(5)设计策略,时间复杂度为(6)(用0符号表示)
【问题3】(3分)
已知数组a={3,10,5,15,6,8},根据说明和C代码,给出数组b的元素值。
试题:
5
阅读下列说明和C++代码,将应填入(n)处的字句写在答题纸的对应栏内
【说明】
某灯具厂商欲生产一个灯具遥控器,该遥控器具有7个可编程的插槽,每个插槽都有开关按钮,对应
(命
着一个不同的灯。
利用该遥控器能够统一控制房间中该厂商所有品牌灯具的开关,现采用Command
令)模式实现该遥控器的软件部分。
Command模式的类图如图1-1所示。
图1-1Command模式类图
【C++代码】classLight{public:
Light(stringname){/*代码省略*/}
voidon(){/*代码省略*/}//开灯
voidoff(){/*代码省略*/}//关灯};
classCommand{
public:
开灯命令
classLightOnCommand:
publicCommand{//private:
Light*light;
public:
LightOnCommand(Light*light){this->light=light;}
voidexecute。
{
(2);}
};
classLightOffCommand:
publicCommand{//关灯命令
private:
Light*light;
public:
LightOffCommand(Light*light){this->light=light;}
voidexecute(){(3);}
};
classRemoteControl{//遥控器
private:
Command*onCommands[7];
Command*offCommands[7];
public:
RemoteControl(){/*代码省略*/}
voidsetCommand(intslot,Command*onCommand.Command*offCommand){
(4)=onCommand;
(5)=offCommand;
}
voidonButtonWasPushed(intslot){(6);}
voidoffButtonWasPushed(intslot){(7);}
};
intmain(){
RemoteControl*remoteControl=newRemoteControl();
Light*livingRoomLight=newLight("LivingRoom");
Light*kitchenLight=newLight("kitchen");
LightOnCommand*livingRoomLightOn=newLightOnCommand(livingRoomLight);LightOffCommand*livingRoomLightOff=newLightOffCommand(livingRoomLight);
LightOnCommand*kitchenLightOn=newLightOnCommand(kitchenLight);
LightOffCommand*kitchenLightOff=newLightOffCommand(kitchenLight);
remoteControl->setCommand(0,livingRoomLightOn,livingRoomLightOff);
remoteControl->setCommand(1,kitchenLightOn,kitchenLightOff);
remoteControl->onButtonWasPushed(O);
remoteControl->offButtonWasPushed(O);
remoteControl->onButtonWasPushed
(1);
remoteControl->offButtonWasPushed
(1);
/*其余代码省略*/
return0;
}
试题:
6
阅读下列说明和Java代码,将应填入(n)处的字句写在答题纸的对应栏内。
【说明】
某灯具厂商欲生产一个灯具遥控器,该遥控器具有7个可编程的插槽,每个插槽都有开关灯具的开关,
现采用Command(命令)模式实现该遥控器的软件部分。
Command模式的类图如图1-1所示。
图1-1Command模式类图
【Java代码】
classLight{
publicLight(){}
publicLight(Stringname){/*
代码省略
*/}
publicvoidon()
{/*
代码省略
*/}//
开灯
publicvoidoff()
{/*
代码省略
*/}//
关灯
//其余代码省略
}
(1){
publicvoidexecute。
;
}
classLightOnCommandimplementsCommand{//开灯命令
Lightlight;
publicLightOnCommand(Lightlight){this.light=light;}
publicvoidexecute(){
(2);}
}
classLightOffCommandimplementsCommand{//关灯命令
Lightlight;
publicLightOffCommand(Lightlight){this.light=light;}
publicvoidexecute(){(3);}
}
classRemoteControl{//遥控器
Command[]onCommands=newCommand[7];
Command[]offCommands=newCommand[7];
publicRemoteControl(){/*代码省略*/}
publicvoidsetCommand(intslot,CommandonCommand,CommandoffCommand){
(4)=onCommand;
(5)=offCommand;
}
publicvoidonButtonWasPushed(intslot){
(6);
}
publicvoidofflButtonWasPushed(intslot){
(7);
}
}
classRemoteLoader{
publicstaticvoidmain(String[]args){
RemoteControlremoteControl=newRemoteControl();
LightlivingRoomLight=newLight("LivingRoom");
LightkitchenLight=newLight("kitchen");
LightOnCommandlivingRoomLightOn=newLightOnCommand(livingRoomLight);
LightOffCommandlivingRoomLightOff=newLightOffCommand(livingRoomLight);
LightOnCommandkitchenLightOn=newLightOnCommand(kitchenLight);LightOffCommandkitchenLightOff=newLightOffCommand(kitchenLight);remoteControl.setCommand(O,livingRoomLightOn,livingRoomLightOff);remoteControl.setCommand(1,kitchenLightOn,kitchenLightOff);remoteControl.onButtonWasPushed(O);
remoteControl.offButtonWasPushed(O);
remoteControl.onButtonWasPushed
(1);remoteControl.offButtonWasPushed
(1);
}
}
答案:
试题一:
【问密】
E1:
客户:
E2;供应商
【问題2】
D1:
鞘警if单表;02:
库存表;D3
主产计划表;[)4;配万表;05;买岡订单轰
【问題3】
CO麺擴流名称
(2)襯擴流名棘
C3)強揭就名務
C4)議据流容務
C5)麹据谥容爾⑹数据谨容称
支付细节:
起点:
财务管理;摒点-C2.
销害订单;起点:
销售订单表:
搭点:
5运送,生产计劃;起点:
茁:
黒点:
3生产,
库存量;起点;02;撬点;4呆!
K1.
原材料做虽;起点:
4栗购:
鬓点:
岸存轰.未完宜订单;起点:
销害订单缶:
悄点:
?
存祐.
试题
U)
医击瞄和飙门*髀主編iiaFffiw.H-iH河霑ti底,环广埒庄
旧7st阳帀茗丙,sinflAi
怙〉齒启w主牡誉蛤&业耒另,蛇蛉卄口丿孙乩业士是舀品芹
LirM)
ios=*T^-+r
ntelKrB^lSk.ftHt»电话
特花.
试题三:
【问題1】
G4:
Eligibla
CI:
Addr«»02:
RidingC3iin»li«ibl*
【I可切
Ml:
1,M2:
*pM3:
**刑:
1*MS:
札W6:
1”
【I嗣】
将Ml与I弭由1I悔我为1+h
试题四:
[|E]HH
(Ob[0]-1
⑵j<=i
⑶n[j]g[i]
⑷b[i]=l«n+1
[问題2】
15)新理规划进(€)0(n^)
[问題3】
b^h.2,2.3,3,41
试题五:
试题六:
Cl)iaceCofTimand
(2)Iight.onO
(3)Iighto*HO
14)onComihands[slot]
C5)offConimands[slot]
(6)onComnbands[fIot]Gx«cuteO
C7)offCoihmands[slot],execute0