For(j=0;len=0;
(2);j++){
If((3)&&len
Len=b[j];
}
(4);
}
Printf(“len:
%d\n”,maxL(b,n));
Printf(“\n”);
}
[问题1]
根据说明和C代码,填充C代码中空
(1)~(4)。
[问题2]
根据说明和C代码,算法采用了(5)设计策略,时间复杂度为(6)(用O符号表示)。
[问题3]
已知数组a={3,10,5,15,6,8},根据说明和C代码,给出数组b的元素值。
试题五
阅读下列说明和C++代码,将应填入(n)处的字句写在答题纸的对应栏内。
[说明]
某灯具厂商欲生产一个灯具遥控器,该遥控器具有7个可编程的插槽,每个插槽都有开关按钮,对应着一个不同的灯。
利用该遥控器能够统一控制房间中该厂商所有品牌灯具的开关,现用Command(命令)模式实现该遥控器的软件部分。
Command模式的类图如图1-1所示。
[C++代码]
ClassLight
{public:
Light(stringname){/*代码省略*/}
Voidon(){/*代码省略*/}//开灯
Voidoff(){/*代码省略*/}//关灯
};
ClassCommand
{public:
(1);
};
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(//遥控器
Priavte:
Command*onCommands[7];
Command*offCommands[7];
Public:
RemoteContorl(){/*代码省略*/}
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*livinRoomLightOff=newLightOffCommand(livingRoomLight);
LightOnCommand*kitchenLightOn=newLightOnCommand(kitchenLight);
LightOnCommand*kitchenLihgtOff=newLightOffCommand(kitchenLight);
remoteControl->setCommand(0,livingRoomLightOn,livingRoomLightOff);
remoteControl->setCommand(1,kitchenLightOn,kitchenLightOff);
remoteConrol->onButtonWasPushed(0);
remoteControl->offButtonWasPushed(0);
remoteControl->onButtonWasPushed
(1);
remoteControl->offButtonWasPushed
(1);
/*其余代码省略*/
Return0;
}
试题六
阅读下列说明和Java代码,将应填入(n)处的字句写在答题纸的对应栏内。
[说明]
某灯具厂商欲生产一个灯具遥控器,该遥控器具有7个可编程的插槽,每个插槽都有开关灯具的开关,现采用Command(命令)模式实现该遥控器的软件部分。
Command模式的类图如图6-1所示。
ClassLight(
PublicLight(Stringname){/*代码省略*/}
Publicvoidon(){/*代码省略*/}//开灯
Publicvoidoff(){/*代码省略*/}//关灯
//其余代码省略
}
(1){
publicvoidexecute();
}
ClassLightOnCommandimplementCommand{//开灯命令
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);
PublicvoidoffButtonWasPushed(intslot){
(7);
}
}
ClassRemoteLoader{
Publicstaticvoidmain(String[]args){
RemoteControlremoteControl=newRemoteControl();
LightlivingRoomLight=newLight(“LivingRoom”);
LightkitchenRoomLight=newLight(“kitchen”);
LightOnCommandlivingRoomLightOn=newLightOnCommand(livingRoomLight);
LightOffCommandlivingRoomLightOff=newLightOffCommand(livingRoomLight);
LightOnCommandkitchenLightOn=newLightOnCommand(kitchenLight);
LightOffCommandkitchenLightOff=newLightOffCommand(kitchenLight);
remoteControl.setCommand(0,livngRoomLightOn,livingRoomLightOff);
remoteControl.setCommand(1,kitchenLightOn,kitchenLightOff);
remoteControl.onButtonWasPushed(0);
remoteControl.offButtonWasPushed(0);
remoteControl.onButtonWasPushed
(1);
remoteControl.offButtonWasPushed
(1);
}
}
Answer:
试题一
[问题1]
E1:
客户
E2:
供应商
[问题2]
D1:
销售订单表
D2:
库存表
D3:
生产计划表
D4:
配方表
D5:
采购订单表
[问题3]
数据流起点终点
支付细节账务管理E2
销售订单D15运送
生产计划D33生产
库存量D2采购
原材料数量4采购D2
未完成的订单销售订单表7存储
试题二
[问题1]
[问题2]
主键外键
(a)超市名称,部门名称超市名称,部门名称超市名称,部门经理
(b)员工号,超市名称,部门名称
(c)商品号商品号,配给时间,业务员商品号,业务员
[问题3]
(1)超市关系中的地址属于复合属性,所谓复合属性就是指属性中含有多种信息,可以进一步拆分的属性,地址可以拆分成多个简单属性,符合这一特征。
(d)1:
n
(e)超市名称,地址,电话
试题三
[问题1]
C1:
Address
C2:
Riding
C3:
Ineligible
C4:
Eligible
[问题2]
M1:
1
M2:
*
M3:
*
M4:
1
M5:
*
M6:
1
[问题3]
将M1与M4由1修改为1..*
试题四
[问题1]
(1)b[0]=1
(2)j<=i
(3)a[j]<=a[i]
(4)b[i]=len+1
[问题2]
(5)动态规划法
(6)O(n*2)
[问题3]
122334
试题五
(1)Virtualvoidexecute()=0
(2)Light->on()
(3)Light->off()
(4)onCommands[slot]
(5)offCommands[slot]
(6)onCommands[slot]->execute()
(7)offCommands[slot]->execute()
试题六
(1)interfaceCommnad
(2)light.on()
(3)light.off()
(4)onCommands[slot]
(5)offCommands[slot]
(6)onCommands[slot].execute()
(7)offCommands[slot].execute()