安全、高速、放心的软件下载

2004年上半年程序员考试题及答案二

时间:2019-05-21 09:30:29来源:不详人气:0
  试题三
  以下是与Visual Basic
对应栏内。
开发应用有关的5个问题.对每

一个问题,请将解答填入答题纸的

  (1)在Visual Basic中
,工程文件、窗体文件和标准模
块文件的扩展名是什么?
  请从下列选项中选择:                                                             prg、prj、exe、vbp、
rom、frm、win、fra,std、bas
、vbs、Vbm

  (2)设某窗体上有一个命令按钮,其
”字样的信息。为使热键 ALT+S 与该命
性设置什么样的属性值?
名称为 CmdSave,运行时该按钮上显示有“保存(S)
令按钮相关联,应该对按钮 CmdSave 的 Caption属


  (3)设某窗口内有一个图像框 Image1
大”按钮就会使该图像框的长和宽都放大
缩小10%(该图像框的左上角不动)。请
码。
,以及两个命令按钮“放大”和“缩小”。单击“放
10%;单击“缩小”按钮就会使该图像框的长和宽都
分别写出这两个命令按钮的单击事件过程中的程序代


  (4)为使某个单选按钮初始时默认被选中,在开发时应怎样做?                    
  (5)若有语句 Tmpval=M
描述程序运行时弹出的消息
sgBox(非法操作!,ybOKCancel
框的主要特征。
+vbCritical,"提示"),请简要


  从下列的2道试题(试题四至试题五)
小的1道解咎有效。
中任选1道解答,如果解答的试题数超过1道,则题号


  试题四
  阅读以下说明和C代码,将应填入__(n)__处的字句写在答题纸的对应栏内。       [说明]                                                                         函数 MultibaseOutput
B(2≤B≤16)进制数并输
B 进制数从栈中输出。有
及栈的类型定义如下:
(long n,int B)的功能是:将
出。该函数先将转换过程中得到
关栈操作的诸函数功能见相应函

一个无符号十进制整数 n 转换成
的各位数字入栈,转换结束后再把
数中的注释。C代码中的符号常量

  #define KAXSIZE 32                                             typedef struct{                                                   int *elem;  /* 栈的存储区 */                                   int max;   /* 栈的容量,即找中最多能存放的元素个数 */           int top;   /* 栈顶指针 */                                       }Stack;                                                                   [C代码]                                                                       int lnitStack(Stack
*S,int n)  /* 创建容量为n
的空栈 */
  { S->elem = (int *)matloc(n * sizeof(int));
  if (S->elem == NULL) return -1;
  S->max = n;__(1)__= 0;return 0;
  }                                                                               int Push(Stack*S,in
t item)   /* 将整数item压
入栈顶 */
  { if(S->top == S->max){ printf("Stack is full!\n");return -1;}
  __(2)__;item;return 0;                                     }                                                                               int StackEmpty(Stack S){ return(
!S.top) ? 1;0;) /* 判断栈是否为空 */
  int Pop(Stack*S)        /* 栈顶元素出栈 */         { if (!S->top){ printf("Pop an empty stack!\n");return -1;)
  return __(3)__;                                                   }                                                                               void MultibaseOutput(long n,int B)             { int m;Stack S;                                                 if (init Stack(&S,MAXSIZE)) { p
rintf("Failure!\n");return;}
  do {                                                                         if (Push(&s,__(4)__
)) { printf("Failure!\n");r
eturn;}
  n = __(5)__:                                                         } while (n != 0);                                               while (!StackEmpty(S
)) {     /* 输出B进制
的数 */
  m = Pop(&S);                                                         if (m < 10) printf("Kd",m);  /* 小于10,输出数字 */
  else printf("%c,m + 55);   
/* 大于或等于10,输出相应的字符 */
  }                                                                               printf("\n");                                                       }                                                                            
  试题五
  阅读以下应用说明及Vi
应栏内。
sual Basic程序代码,将应填入

__(n)__处的字句写在答题纸的对

  [应用说明5.1]                                                               本应用程序的窗体中有
Txtl和Txt2)。运行时,用
号(从0开始)分别在文本
一个下拉式列表框(名称为Comb
户从Combol的列表中进行选择,
框 Txt1 和 Txt2 中显示出来。
ol)和两个文本框(名称分别为
程序就会将选中条目的内容以及编

  [程序代码5.1]                                                               Private Sub Combol_C1ick()                             Txtl.Text = Combol.__(1)__                             Txt2.Text = Combol.__(2)__                             End Sub                                                                   (注:可供(2)处选择的选项:List
,Index,Listlndex,ListCount,Number)
  [应用说明5.2]                                                               本应用程序的运行窗口如下图所示:                                              
  

  当用户在输入框(名为
择所需的运算后,输出框(
为CmdClear)后,输入框和
Txtln)中输入数值数据,并从
名为TxtOut)中就会显示运算的
输出框都清空。
下拉式列表框(名为CmbOp)中选
结果。用户单击“清除”按钮(名

  开发该应用的部分程序代码如下:                                                   [程序代码5.2]                                                               Private Sub CmbOp_Click()                               Dim DataIn As Double,DataOut as Double     DataIn = __(3)__                                                 Select Case __(4)__                                           Case "取整数部分"                                                         DataOut = Int(Dataln)                                       Case "求平方根"                                                           If Dataln < O Then
  MsgBox$("负数不能开平方!")                                           Else                                                                         DataOut = Sqr(Dataln)                                       End If                                                                     Case "取绝对值"                                                           DataOut = Abs(Dataln)                                       (TxtOut.Text = str$(DataOut)                         __5)__                                                                     End Sub                                                                
  从下列的2道试题(试题六至试题七)
小的1道解答有效。
中任选1道解答。如果解答的试题数超过1道,则题号


  试题六
  阅读下列函数说明和 C
函数,将应填入__(n)__处的字
句写在答题纸的对应栏内。
  [函数6说明]                                                                   函数DelAInsB(LinkedL
是,将线性表A中关键码为k
key2的结点之前,若移动成
表,La为表A的头指针,Lb
ist La,LinkedList lb,int k
eyl的结点开始的len个结点,按
功,则返回0;否则返回-1。线
为表B的头指针。单链表结点的
ey1,int key2,int len)的功能
原顺序移至线性表B中关键码为
性表的存储结构为带头结点的单链
类型定义为:
  typedef struct node{                                         int key;                                                                 struct node*next;                                               }*Linkedhist;                                                       [函数6]                                                                       int DelllnsB(LinkedLiSt La,Link
edList Lb,int keyl,int key2,int len)
  { LinkedList p,q,S,prep,pres;                       int k;                                                                     if (!La->next || !Lb->next || len<=0) return-1;
  p = La->next; prep = La;
  while (p && p->key != keyl){   /* 查找表A中键值为key1的结点 */
  prep = p; p = p->next;
  }                                                                               if (!p) return -1;
        /* 表A中不存
在键值为key1的结点 */
  q = p; k = 1;                                                       while (q && __(1)__){     
  /* 在表A中找出待删除的len个结点 */
  __(2)__: k++;                                                       }                                                                               if (!q) return -1;      

  /* 表A中不存在要被删除的len个结点 */

  S = Lb->next;__ (3)__;
  while (s && s->key != key2){   /* 查找表B中键值为key2的结点 */
  pres = s; s = s->next;
  }                                                                               if (!s)return -1; 
       /* 表B中不存在
键值为key2的结点 */
  __(4)__q->next;         /* 将表A中的len个结点删除 */
  q->next:__(5)__
  pres->next = p;         /* 将len个结点移至表B */
  return 0;                                                               }                                                                            
  试题七
  阅读以下应用说明、属
答题纸的对应栏内。
性设置及VisualBasic程序代码

,将应填入__(n)__处的字句写在

  [应用说明7]                                                                   本应用程序的运行窗口如下图所示:                                              
  

  只要用户单击“闪烁”按钮,文字“
烁;单击“停止”按钮时,闪烁停止,恢
欢迎光临”就会以0.3秒消失、0.3秒显示反复进行闪
复图示的初态。
  在开发过程中,需要设置的属性如下:                                               [属性设置7]                                                                
  

  在开发过程中,需要编写的程序代码如下;                                           [程序代码7]                                                                   Private Sub CmdF Click()                                 Timerl.__(3)__ = True                                       Label.Visible = False                                       End Sub                                                                   Private Sub Timerl_ Timer()                           __(4)__ = not Label.Visible                           End Sub                                                                   Private Sub CmdT Click()                                 Timerl.Enabled = __(5)__                                 Label.Visible = true                                         End Sub                                                                
  从下列的2道试题(试题八至试题九
号小的1道解答有效。
)中任选1道解答,如果解答的试题数超过1道,则题


  试题八
  阅读下列程序说明和C程序,将应填入__(n)__处的字句写在答题纸的对应栏内。   [程序8说明]                                                                   程序8用于计算某公司
。职工的当月收入(工资或
。由于该公司的工资或薪金
,整个输入以工号小于等于
每个职工应缴纳的个人所得税额
薪金)通过键盘输入,每次输入
是不定时发放的,所以输入过程
0结束。
和全体职工缴纳的个人所得税总额
一个职工的工号和工资(或薪金)
中每个职工的收入会出现多次输入

  假设个人所得税法规定
后的余额作为该月的月应纳
;个人收入所得,按月计税,以
税所得额,适用税率如下表所示
每月收入总额减除免税金额800元


  

  上表表明,个人收入所得税是按照超额累进的税率来征收的。                           设一个人的月应纳税所
得额为K(元),用下面的公式计
算其应缴纳的个人所得税额S(元):
  若0
  若500
  若2000
  若5000
  例如,某人某月工资总
个人所得税额为500*5%+15
额为4100元,减去800元后,应
00*10%+1300*15%=370元。
纳税所得额为3300元,其应缴纳的

  [程序8]                                                                       #include 
  #define MaxNum 50                                               #define BASE 800     /*免税金额基数*/                   int paylevel[]={0,5
¨:
00,2000,5000,20000,40000

,60000,80000,100000,100000

  int taxPrate[]={5,10,15,20,2
5,30,35,40,45): /*税率表*/
  typedef struct{                                                   int ld;    /*职工的工号*/ .                                     long Salary;  /*职工的工资*/                                   }Info;                                                                     /* 查找工号为Id的职
工在数组employee中的下标,返
回值为0表示没有 */
  int find(int ld,Info employee[],int m){   int j;                                                                     employee[0].Id=Id;                                             for(j=m;__(1)__;j--);                                       return j;                                                               }                                                                               void main(void)                                                   { Info employeeCHaxNum+1];                             long Wage;                                                             double sum s 0,K,S:                                           int i,j,N=0,Code;                                               scanf("M%ld",&Code
,&Wage);   /*读入职工号
、工资或薪金*/
  while(Code>0) {
  i=find(Code,employee,N);                                 if (i>0)employee[i].Salary += Wage:
  else{ __ (2)__;                                                   employee[N].Id=Code;employee[N
].Salary=Wage;
  }                                                                               scanf("%d%ld",&Code,&Wage):                           }                                                                               for (i=1;i<=N;i++){
  K = __(3)__;         /*计算月应纳税所得额*/             S=0;             /*月应纳税额赋初值*/                       if (K > 0) {
  for (j=1;j<=9;j++)
  if(__(4)__)        /*月应纳税所得额超过第j级*/           S=S+(paylevel[j]-pa
ylevel[j-1])*taxPrate[j-1]/1
00;
  else{ S=S+(__ (5)__)*taxPrate[
j-1]/100;break;}
  }                                                                               printf("职工%d应缴
纳的个人所得税额:%10.21f\n
",employee[i].Id,S);
  sum += S;                                                               }                                                                               printf("全体职工个人所得税总额:%10,21f\n",sum);         }                                                                            
  试题九
  阅读以下应用说明及Vi
栏内.
sualBasic程序代码,将应填入_

_(n)__处的字句写在答题纸的对应

  [应用说明9]                                                                   本应用程序的运行窗口如下图所示:                                              
  

  窗口中的三个文本框和两个按钮名称
compute和Cmd_quit.运行时,文本框Txt
)。当用户在文本框ht_salary中输入月
后,Txt_tax框中就显示计算所得的应纳
户输入,Txt_base的内容以灰色显示。
分别为Txt_salary、Txt_base、ht_tax、Cmd
_base中存放的是免税金额基数(应扣除的基本费用
收入(工资或薪金)并单击“计算”按钮Crud_compute
税额。文本框Txt_base和Txt_tax在运行时不接受用

  个人工资(或薪金)所得
免税金额基数后的余额作为
税率进行累进计算.目前的
税是按照超额累进的税率来征收
该月的月应纳税所得额,再将应
免税金额基数为800元,税率如
的,方法是:以每月收入总额减去
纳税所得额按相应级数采用相应的
下表所示:
  个人工资(或薪金)所得税是按照超额
免税金额基数后的余额作为该月的月应纳
税率进行累进计算.目前的免税金额基数
累进的税率来征收的,方法是:以每月收入总额减去
税所得额,再将应纳税所得额按相应级数采用相应的
为800元,税率如下表所示:

  

  设一个人的月应纳税所得额为K(元)

,用下面的公式计算其应缴纳的个人所得税额S(元)

  若0
  若500
  若2000
  若5000
  例如,某人某月工资总
个人所得税额为500*5%+15
额为4100元,减去800元后,应
00*10%+1300*15%=370元。
纳税所得额为3300元,其应缴纳的

  在开发过程中,需要编写的程序代码如下:                                           [程序代码]                                                                     Option Base 0                                                       Private Sub Cmd compute-C1ick()                   Dim paylevel,taxPrate                                       paylevel=Array(0,500,2000,50
1000001)
00,20000,40000,60000,80000,100000,

  taxPrate=Array(5,10,15,20,2
5,30,35,40,45)
  K=__(1)__                                                               S = 0                                                                       If (K>0) Then
  For j=1 To 9                                                         If __(2)__ Then                                                   S=S+(paylevel(j)-paylevel(j-1))
*taxPrate(j-1)/100
  Else                                                                         S=S+(__(3)__)*taxPrate(j-1)/100                   Exit For                                                                 End lf                                                                     Next j                                                                     End lf                                                                     __(4)__=Str$(S)                                                   End Sub                                                                
  Private Sub Cmd_quit_C1ick()                         End                                                                           End Sub                                                                
  Private Sub Form_Load()                                   Txt_tax.Text = " "                                             Txt_salary.Text = " "                                       Txt_base.Text = 800                                           Txt_tax.Locked = True                                       Txt_base.Enabled =__(5)__                               End Sub                                                                   
2004年上半年程序员级答案


  上午答案
  

  下午答案
  试题一
  (1)j ← j-1                                                             (2)I ← i+1                                                             (3)A[i]←povot 或 [j]←povot                               (4)A,L,k-I 或A,L,k                                               (5)A,k+I,H 或A,k,H                                            
  试题二
  (1)*pi == *pi                                                       (2)pi
  (3)str[i] == del                                                 (4)str[j]                                                               (5) i = j+1                                                        
  试题三
  (1)工程文件的扩展名是 vbp,窗体

文件的扩展名是 frm,标准模块文件的扩展名是 bas

  (2)保存(&S)                                                               (3)解答:“放大”按钮单击事件过程中的程序代码:                               Image1.Width=Image1.Width*1.1                       1mage1.Height=Image1.Height*1.1                   “缩小”按钮单击事件过程中的程序代码:                                           Image1.Width=Image1.Width*0.9                       1mage1.Height=Image1.Height*0.9                   (4)将该单选按钮的Value属性值设置成True                               (5)消息框的标题栏显示“提示”:
示“确定”和“取消”;消息框中显示的
消息框中有一个出错标记以及两个命令按钮,分别显
信息为“非法操作!”。

  试题四
  (1)S->top
  (2)S->elem[S->top++]•
  (3)S->elem[-S->top]
  (4)n % B                                                                 (5)n / B                                                              
  试题五
  (1)Text                                                                   (2)listlndex                                                         (3)Val(Txtln.Text) 或Txtln.Text                     (4)CmbOp.Text                                                       (5)EndSelect                                                      
  试题六
  (1)k<1en
  (2)q=q->next 或 q=(*q).next
  (3)pres = Lb                                                         (4)prep->next或(*prep).next
  (5)s 或 pres->next 或 (*pres).next

  试题七
  (1)false                                                                 (2)300                                                                     (3)enabled                                                             (4)Label.Visible                                                 (5)false                                                              
  试题八
  (1)employee[j].Id!=Id                                       (2)++N 或 N++ 或 N=N+1                                         (3)employee[i].Salary-BASE                             (4)k>payleve[j]
  (5)k>payleve[j-1]

  试题九
  (1)Val(Txt_salary.Te
xt)-Val(Txt_base.Text)

  (2)k>paylevel(j)
  (3)k-paylevel(j-1)                                             (4)Txt_tax.Text                                                   (5)False   
网友评论