考试总分:8分
考试类型:模拟试题
作答时间:60分钟
已答人数:967
试卷答案:有
试卷介绍: 2004年下半年程序员下午试卷
A(1)__;i<n-1;__
B(2)__={if(a>a[I+1]){t=a;a=a[I+1];a[I+1]=t;tag=0;}}tag++if(__
C(3)__)break;}}对包含十个元素的数组a采用上述方法排序时,元素间的比较次数最少为__
D(4)__次,最多为__
E(5)__次。[15分]
A(1)__){/*查找第I个元素并使指针p指向该结点*/Prep=p;p=p->next;k++}if(!p||k>i)return-1;if(__
B(2)__)/*第I个元素结点已经是表尾结点,则无需移动*/return0;q=p;while(__
C(3)__)q=q-﹥next;/*查找表尾并使q指向表尾结点*/__
D(4)__=p->next;p->next=NULL;__
E(5)__;return0;}[15分]
A(1){/*录入一名选手提交答案的信息(小时:分钟,选手编号,题目号,是否正确)*/scanf(”%d:%d,%d,%c”,&h,&m,&k,&ch,&pass);if(h==0)break;R[k]no=k;Time=__(1)__;If(isupper(ch))ch=’a’+ch-‘A’;If(pass!=’Y’&&pass!=’Y’){R[k]d[ch-‘a’]++;continue;}If(R[k]a[ch-‘a’]==1)continue;R[k]a[ch-‘a’]=1;R[k]num++;R[k]time+=__
B(2)__;if(k>MaxIndex)MaxIndex=k;}/*while*/for(I=1;I<MaxIndex;I++){/*选择排序*/for(t=I,j=I+1;j<=MaxIndex;j++)if(R[t]num<R[j]num||__
C(3)__t=j;)if(__
D(4)__){R[0]=R[t];R[t]=R[i];R[i]=R[0];}}/*for*/k=1;R[0]=R[1];for(I=1;I0){if(Rnum!=R[0].num||R[i].time!=R[0]time)k++;R[0]=__
E(5)__;Printf(“%d:%3d%4d%5d\n”,k,Rno,RnumRtime);}/*if*/}/*Statistic*/[15分]
A(1)__)NextCombol.text=combol.list(0):txt_time.text=””:txt_player.text=””Fori=1to300R(i).num=0:R(i).time=0:R(i).no=iForj=1to8R(i).d(j)=0:R(i).a(j)=falseNextj,iEndSubPrivatesubcmd_confirm_click()Dimh,m,k,timeasinteger,ch,pass,s1asstringK=Instr(txt_time.text,”:”):ifk11orh=11andm>0orm>=60thengotoerror1Time=__
B(2)__’计算答题时间,以分钟为单位Iftxt_plater.text300thengotoerror1Ch=__
C(3)__Pass=IIf(chk_yn.__
D(4)__=0,”N”,”Y”)S1=txt_time.text+space(4)+txt_player.textS1=s1+space(10-len(txt_player.text))+ch+space(8)+passList1.additems1K=val(txt_player.text)'k为选手编号R(k).no=k'编号为k的选手的提交信息记录在下标为k的数组元素中Ifk>maxindexthenmaxindex=kM=asc(ch)-asc(“a”)Ifpass”Y”then'编号为k的选手提交第m个题目的解答不正确R(k).d(m)=R(k).d(m)+1ElseifR(k).a(m)truethen'已经提交正确的题目的解答不再计算R(k).a(m)=true:R(k).num=R(k).num+1R(k).time=R(k).time+__
E(5)__Callstatistic'调用过程statistic进行实时排名和输出EndifExitsubError1:msgbox”录入信息有错误!”,vbOKOnlyEndsub[15分]
A(1)__endifendsubprivatesubcmd_add_click()'单击“增加”按钮的代码callenableop(__
B(2)__)data1.recordset.addnew'在数据库表中添加一个新记录txt_name.__
C(3)__endsubprivatesubcmd_del_click()'单击“删除”按钮的代码onerrorgotoerror3ans=msgbox(“确定删除吗?”,vbYesNo+vbInformation,”操作提示!”)if(ans=vbyes)thendata1.recordset.__
D(4)__data1.recordset.movenextifdata1.recordset.Eofthendata1.refreshendifexitsuberror3:msgboxerr.description,vbokonly,”错误提示!”endsubprivatesubcmd_ok_click()'单击确定按钮的代码onerrorgotoerror1data1.recordset.__
E(5)__callenableop(false)exitsuberror1:msgboxerr.description,vbokonly,”错误提示!”data1,updatecontrolscallenableop(false)endsub'修改和取消按钮的程序代码略[15分]
A(1)__处按“循环变量名:循环初值,增量,循环终值”格式描述。[15分]
A(1)__{protected:doubleheight;doublewidth;public:Rectangle(){};Rectangle(doubleheight,doublewidth){This->height=height;This->width=width;}doublegetarea(){return__
B(2)__;}};classSquare:__
C(3)__{public:square(doublewidth){__
D(4)__;}};classtriangle:__
E(5)__{doublela;doublelb;doublelc;public:triangle(doublela,doublelb,doublelc){this->la=la;this->lb;this->lc;}doublegetArea(){doubles=(la+lb+lc)/2.0;returnsqrt(s*(s-la)**(s-lb)*(s-lc));}};viodmain(){figure*figures[3]={newtriangle(2,3,3),newRectangle(5,8),newSquare(5)};for(inti=0;igetarea()<<endl;}}};[15分]
A(1)__{doubleheight;doublewidth;publicrectangle(doubleheight,doublewidth){this.height=height;this.width=width;}publicstringtostring(){return”rectangle:height=”+height+”,width=”+width+”:”;}publicdoublegetarea(){return__
B(2)__}}publicclasssquareexends__
C(3)__{publicsquare(doublewidth){__
D(5)};for(inti=0;i<Figures.length;i++){system.out.println(Figures+”area=”+Figures.getarea());}}}publicabstractclassfigure{publicabstractdoublegetarea();}publicclassrectangleextends__(1)__{doubleheight;doublewidth;publicrectangle(doubleheight,doublewidth){this.height=height;this.width=width;}publicstringtostring(){return”rectangle:height=”+height+”,width=”+width+”:”;}publicdoublegetarea(){return__(2)__}}publicclasssquareexends__(3)__{publicsquare(doublewidth){__
E(5)};for(inti=0;i<Figures.length;i++){system.out.println(Figures+”area=”+Figures.getarea());}}}publicabstractclassfigure{publicabstractdoublegetarea();}publicclassrectangleextends__(1)__{doubleheight;doublewidth;publicrectangle(doubleheight,doublewidth){this.height=height;this.width=width;}publicstringtostring(){return”rectangle:height=”+height+”,width=”+width+”:”;}publicdoublegetarea(){return__(2)__}}publicclasssquareexends__(3)__{publicsquare(doublewidth){__(4)__;}publicstringtostring(){return”square:width=”+width”:”;}}publicclassrectangleentend__(5)__{doublela;doublelb;doublelc;publictriangle(doublela,doublelb,doublelc){this.la=la;this.lb=lb;this.lc=lc;}publicstringtostring(){return”triangle:sides=”+la+”,”+lb+”,”+lc+”:”;}publicdoublegetarea(){doubles=(la+lb+lc)/2.0;returnmath.sqrt(s*(s-la)*(s-lb)*(s-lc));}}[15分]