首页 > 软考
题目内容 (请给出正确答案)
[主观题]

阅读以下应用程序说明和C程序,将C程序段中(1)~(7)空缺处的语句填写完整。【说明】 某超市集团为发展

阅读以下应用程序说明和C程序,将C程序段中(1)~(7)空缺处的语句填写完整。

【说明】

某超市集团为发展业务向社会公开招聘N个工种的工作人员,每个工种各有不同的编号(1至M)和计划招聘人数。每位应聘者需申报两个工种,并参加集团组织的考试。该集团公司将按应聘者的成绩从高分至低分的顺序进行排队录取。具体录取原则是:从高分到低分依次对每位应聘者先按其第一志愿录取;当不能按其第一志愿录取时,便将他的成绩扣去5分后,重新排队,并按其第二志愿录取。

以下C程序为输出各工种实际招聘的应聘人员,每个工种都保留一个录取者的有序队列。录取处理循环直至招聘额满或已对全部应聘者都作了录取处理后跳出。

C程序中,类型STU包含有应聘者的基本信息:编号、成绩、志愿、排队成绩和录取志愿号。数组 rzl)的每个元素对应一个工种,包含有计划招聘人数和已录取的人数。

【C程序】

include

define N 36

define EDMARK 5

typedef struct stu {

int no, total, z[2], sortm, zi;

struct stu *next;

} STU;

struct rznode {

int lmt, count;

STU *next;

} rz [N];

STU *head = NULL, *over = NULL;

int all

FILE *fp;

char dataf [ ] = "zp2008.dat" ;

print(STU *p)

{ for (;p!=NULL; p = p->next)

printf("%d(%d) \t" , p->no, p->total

}

insert(STU **p, STU *u)

{ STU *v, *q;

for (q = *p;q != NULL; v = q , (1) )

if (q-> sortm < u->sortm)

break;

if (q == *p)

(2);

else

(3);

u->next = q ;

}

main ()

{ int zn, i, no, total, zl, z2 ;

STU *p, *v, *q;

fp = fopen(dataf, "r" );

if (fp == NULL)

{ printf ("Can't open file %s.kn" ,dataf);

exit (0);

}

fscanf (fp, "%d" ,&zn);

for (all = 0, i = 1; i <= zn; i++)

{ fscanf (fp, "%d", &rz [ i ].lmt ;

rz[i].count = 0;

rz[i].next = NULL;

all +=(4);

}

for (;;)

{ if ((fscanf(fp, "%d%d%d%d" ,&no,&total,&zl,&z2)) != 4 )

break;

p = (STU *) malloc (sizeof (STU));

p->no = no;

p->total = p->sortm = total;

p->zi = 0;

p->z[0] = z1;

p->z[1] = z2;

(5);

}

fclose (fp);

for (;all && head != NULL;)

{ p = head;

head = head->next;

if (rz[p->z[p->zi]].count <(6))

{ rz[p->z[p->zi]].count ++;

insert(&rz[p->z[p->zi]].next,p);

all--;

continue;

}

if (p->zi >= 1 )

{ p->next = over;

ver = p;

continue;

}

p->sortm -= DEMARK;

(7);

insert(&head,p);

}

for (i = 1; i <= zn; i++ )

{ printf("%d:\n" ,i);

print(rz[i ].next);

printf(" \n");

}

printf("over:\n" );

print(head);

print(over);

printf(" \n");

}

查看答案
答案
收藏
如果结果不匹配,请 联系老师 获取答案
您可能会需要:
您的账号:,可能还需要:
您的账号:
发送账号密码至手机
发送
安装优题宝APP,拍照搜题省时又省心!
更多“阅读以下应用程序说明和C程序,将C程序段中(1)~(7)空缺…”相关的问题
第1题
●试题五 阅读以下应用说明、属性设置及Visual Basic程序代码,将应填入(n)处在字句写在答题纸的对

●试题五

阅读以下应用说明、属性设置及Visual Basic程序代码,将应填入(n)处在字句写在答题纸的对应栏内。

【说明】

本应用程序的运行窗口如图2所示。

●试题五 阅读以下应用说明、属性设置及Visual Basic程序代码,将应填入(n)处在字句写在答

只要用户单击"闪烁"按钮,文字"欢迎光临"就会以0.3秒消失、0.3秒显示反复进行闪烁;单击"停止"按钮时,闪烁停止,恢复图示的初态。

在开发过程中,需要设置的属性如表1所示。

●试题五 阅读以下应用说明、属性设置及Visual Basic程序代码,将应填入(n)处在字句写在答

在开发过程中,需要编写的程序代码如下:

【程序】

Private Sub CmdF_Click()

Timer1. (3) =True

Labe1.Visible=False

End Sub

Private Sub Timer1_Timer()

(4) =not Label.Visible

End Sub

Private Sub CmdT_Click()

Timer1.Enabled= (5)

Labe1.Visible=true

End Sub

点击查看答案
第2题
阅读以下应用程序说明和C程序,将C程序段中(1)—(7)空缺处的语句填写完整。[说明] 打保龄球是用一个

阅读以下应用程序说明和C程序,将C程序段中(1)—(7)空缺处的语句填写完整。

[说明]

打保龄球是用一个滚球去打出10个站立的柱,将柱击倒。一局分10轮,每轮可滚球一次或多次,以击倒的柱数为依据计分。一局得分为10轮得分之和,而每轮的得分不仅与本轮滚球情况有关,还可能与后续一两轮的滚球情况有关。即某轮某次滚球击倒的柱数不仅要计入本轮得分,还可能会计入前一两轮得分。具体的滚球击柱规则和计分方法如下:

1) 若某一轮的第一次滚球击倒全部10个柱,则本轮不再滚球(若是第10轮则还需另加两次滚球)。该轮得分为本次倒柱数(即10)与以后两次滚球所击倒柱数之和。

2) 若某一轮的第一次滚球未击倒10个柱,则可对剩下未倒的柱再滚球一次。如果这两次滚球击倒全部10个柱,则本轮不再滚球(若是第10轮则还需另加一次滚球),该轮得分为本次倒柱数10与以后一次滚球所击倒柱数之和。

3) 若某一轮的两次滚球未击倒全部10个柱,则本轮不再继续滚球,该轮得分为这两次滚球击倒的柱数之和。

总之,若一轮中一次滚球或两次滚球击倒10个柱,则本轮得分是本轮首次滚球开始的连续3次滚球击倒柱数之和(其中有一次或两次不是本轮滚球)。若一轮内二次滚球击倒柱数不足10个,则本轮得分即为这两次击倒柱数之和。表3-15是打保龄球计分的某个实例说明。

阅读以下应用程序说明和C程序,将C程序段中(1)—(7)空缺处的语句填写完整。[说明] 打保龄球是用

以下[C程序]是模拟打一局保龄球的过程,统计各轮得分和累计总分。程序交互地逐轮逐次输入一次滚球击倒的柱数,计算该轮得分和累计总分。为记录一轮内击倒10柱,但还暂不能计算该轮得分和累计总分的情况,程序引入变量ok,用来记录当前已完成完整计算的轮次。程序每输入一次滚球击倒柱数,就检查还未完成完整计算的轮次,并计算。

[C程序]

include<stdio.h>

define N 13

struct { int n; /* 一轮内滚球次球 */

int f; /* 第一次击倒柱数 */

int s; /* 第一次击倒柱数 */

int score; /* 本轮得分 */

int total; /* 至本轮累计总分 */

int m; /* 完成本轮得分计算,还需滚球次数 */

} a[N];

int k = 0; /* 已完成完整计算的轮次数 */

int ball(int i, int n, int max) /* 完成一次滚球,输入正确击倒柱数 */

{ int d, j, k;

static c=1;

while (1)

{ if(i <= 10)

printf(" 输入第%d轮的第%d次滚球击倒柱数。(<=%d)\n", i, n, max );

else

printf(" 输入附加的第%d次滚球击倒柱数。(<=%d)\n", C++, max);

scanf("%d , &d);

if (d >=0 && d <= max) break;

printf(" 不合理的击倒柱数,请重新输入。\n")

)

if (ok <(1) )

{ /* 对以前未完成计算的轮次分别计算得分与累计总分*/

for(j = ok+1;(2); j++)

{ a[j].score += d;

if (--a[j].m == 0)

{ a[j].total = ((3) ) + a[j].score;

k =(4);

}

}

}

return d;

}

main ()

{ int i, first, second, k; /* i表示轮次 */

for (i = 1 ; ok < 10 ; i++)

a[i].score = a[i].f = first = ball(i,1,10);

if (first == 10)

a[i].m = 2;

a[i].n = 1;

if (first < 10 && (i <= 10 || i == 11 && ok < 10 ))

{ /* 处理第2次滚球 */

(5)= second = ball i,2,10-first);

if (first + second == 10)

a[i].m = 1;

点击查看答案
第3题
阅读以下应用说明及Visual Basic程序代码,将应填入(n)处的字句写在对应栏内。【应用说明5.1】 本应

阅读以下应用说明及Visual Basic程序代码,将应填入(n)处的字句写在对应栏内。

【应用说明5.1】

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

【程序代码5.1】

Private Sub Combo1_Click()

Txt1.Text = Combo1. (1)

Txt2.Text = Combo1. (2)

End Sub

(注:可供(2)处选择的选项:List, Index, Listlndex, ListCount, Number)

【应用说明5.2】

本应用程序的运行窗口如图2所示。

阅读以下应用说明及Visual Basic程序代码,将应填入(n)处的字句写在对应栏内。【应用说明5

开发该应用的部分程序代码如下:

【程序代码5.2】

Private Sub CmbOp_Click()

Dim Dataln As Double,DataOut as Double

Dataln=(3)

Select Case (4)

Case "取整数部分"

DataOut =Int(Dataln)

Case "求平方根"

If Dataln<0 Then

MagBox "负数不能开平方!"

Else

DataOut = Sqr(Dataln)

End If

Case "取绝对值"

DataOut = Abs(Dataln)

(5)

TxtOut. Text = str $ (DataOut)

End Sub

点击查看答案
第4题
阅读以下程序段,将空白处填写完整()。

If(cb_save.isChecked()){

//如何将name和psd追加到login.xml文件中

SharedPreferences.Editoreditor=sp.edit();

Eidtor.putString("user",name);

Editor.putString("password",psd);

Editor.();

}

A.edit

B.editor

C.putString

D.mit

点击查看答案
第5题
●试题八 阅读以下说明及Visual Basic部分程序代码,将应填入(n)处的字句写在答题纸的对应栏内。

●试题八

阅读以下说明及Visual Basic部分程序代码,将应填入(n)处的字句写在答题纸的对应栏内。

【说明】

本程序是一个可进行数制转换的应用程序,图1所示是其运行界面。txtDec为TextBox控件名,Lblkes为转换结果labe1控件名。

●试题八 阅读以下说明及Visual Basic部分程序代码,将应填入(n)处的字句写在答题纸的对应

【程序代码】

Option Explicit

Private Function convert(pintDec As Intege,pintS As Integer)As String

Dim intCt As Integer,intR As Integer

Dim strCov As String,strRes As String

intR=pintDec Mod pintS

Do While (1)

strCov=strCov & Str(intR)

(2)

intR=pintDec Mod pintS

Loop

For intCt= (3) To 1 Step-1

strRes=strRes & Mid(strCov,intCt,1)

Next intCt

convert=strRes

End Function

Private Sub cmdQuit_Click()′退出

Unload Me

End Sub

Private Sub optBin_Click()′二进制

lblRes.Caption="转换结果:"& (4)

End Sub

Private Sub optHex_Click()′十六进制

lblRes.Caption="转换结果:"& (5)

End Sub

Private Sub optOct_Click()′八进制

lblRes.Caption="转换结果:"&Oct(Val(txtDe

C.Text))

End Sub

点击查看答案
第6题
阅读以下程序说明和C++程序,将程序段中(1)~(5)空缺处的语句填写完整。【说明】 以下【C++程序】实现一

阅读以下程序说明和C++程序,将程序段中(1)~(5)空缺处的语句填写完整。

【说明】

以下【C++程序】实现一个简单的小型复数类MiniComplex,该复数类能进行输入、输出、复数的加法、减法、乘法和除法运算,还可以进行复数的相等比较。

【C++程序】

ifndef H_MiniComplex

define H_MiniComplex

include <iostream>

using namespace std;

class MiniComplex{

public: //重载流插入和提取运算符

(1) ostream&operator<<(ostream &osObject,const MiniComplex&complex){

osObject<<"("<<complex.realPart<<"+"<<complex.imagPart<<"i"<<")";

return osObject;

}

(2) istream&operator>>(istream&isObject, MiniComplex&complex){

char ch;

isObject >>complex.realPart>>ch>>complex.imagPart>>ch;

return isObject;

}

MiniComplex(double real=0,double imag=0); //构造函数

MiniComplex operator+(const MiniComplex&otherComplex)const; //重载运算符+

MiniComplex operator-(const MiniComplex&otherComplex)const; //重载运算符-

MiniComplex operator*(const MiniComplex&otherComplex)const; //重载运算符*

MiniComplex operator/(const MiniComplex&otherComplex)const; //重载运算符/

bool perator==(const MiniComplex&otherComplex)const; //重载运算符==

private :

double (3);

double imagPart;

};

end if

include "MiniComplex.h"

bool MiniComplex::operator==(const MiniComplex&otherComplex)const{

return(realPart==otherComplex.realPart&&imagPart==ortherComplex.imagPart);

}

MiniComplex::MiniComplex(double real,double imag){

realPart== real; imagPart==imagPart;

}

MiniComplex MiniComplex::operator+(const MiniComplex&otherComplex)const{

MiniComplex temp;

temp.realPart = realPart+ortherComplex. realPart;

temp.imagPart = imagPart +ortherComplex. imagPart;

return temp;

}

(4)

{ MiniComplex temp;

temp.realPart= realPart-ortherComplex. realPart;

temp.imagPart = imagPart-ortherComplex. imagPart;

return temp;

}

MiniComplex MiniComplex::operator*(const MiniComplex&otherComplex)const{

MiniComplex temp;

temp.realPart = (realPart*ortherComplex. realPart)-(imagPart *ortherComplex.imagPart);

temp.imagPart = (realPart*ortherComplex. imagPart)+(imagPart *ortherComplex.realPart);

return temp;

}

MiniComplex MiniComplex::operator/(const MiniComplex&otherComplex)const{

MiniComplex temp;

float tt;

tt=1/(ortherComplex.realPart*ortherComplex.realPart+ortherComplex.imagPart *ortherComplex. imagPart);

temp.realPart=((realPart*ortherComplex, realPart)+(imagPart *ortherComplex. imagPart))*tt;

temp.imagPart =((imagPart *ortherComplex. realPart)-(realPart*ortherComplex. imagPart))*tt;

return temp;

}

include <iostream>

include <MiniComplex.h>

using namespace std;

int main(){

MiniComplex numl(23, 34),num2(56, 35);

cout<<"Initial Value of num1="<<num1<<"\n Initial Value of num2="<<num2<<end1;

cout<<num1<<"+"<<num2<<"="<<num1+num2<<end1; //使用重载的加号运算符

cout<<num1<<"-"<<num2<<"="<<num

点击查看答案
第7题
阅读下列程序段,说明程序段的功能。

阅读下列程序段,说明程序段的功能。

请帮忙给出正确答案和分析,谢谢!

点击查看答案
第8题
阅读以下说明和C程序,将填入(n)处的字句在对应栏内。 [说明] 某旅游服务应用程序运行时,根据输入

阅读以下说明和C程序,将填入 (n) 处的字句在对应栏内。

[说明]

某旅游服务应用程序运行时,根据输入的两个城市名查找其问的距离。各城市问的距离如表4-1所示。表格中的第一行和第一列表示城市名,表中的每个元素是一个整数,代表该元素所在行和列对应的城市之间的距离(单位:km)。

表4-1

阅读以下说明和C程序,将填入(n)处的字句在对应栏内。 [说明] 某旅游服务应用程序运行时,根据输入

在程序中,城市名用一维全局数组cityTable存储,城市之间的距离矩阵用二维全局数组kmTable表示,并用相应的值对这两个数组进行初始化。

define NCities 8 /*城市个数*/

define TRUE 1

static char * cityTable[NCities]={ /*城市名按字典序升序排列*/

"Beijing",

…… /*其他城市名略去*/

"Sanya",

};

StatiC int kmTable[NCities][NCities]={

{0, 1697, 2695, 937, 1784, 1356, 926, 2543},

{1697, 0, 313, 1840, 533, 940, 1409,1505},

…… /*剩余元素的初始值略去*/

};

程序执行时,首先按提示输入两个城市名,然后在cityTable中查找与城市名对应的下标,最后用该下标在kmTable中找到这两个城市之间的距离。

程序中定义的函数FindCitylnSortedArray和GetCity说明如下:

(1)函数FindCitylnSortedArray的功能是用二分查找法在全局数组cityTable中查找城市名所对应的下标值。

(2)函数GetCity的功能是读入城市名,调用函数FindCityInSortedArray来获取城市所对应的下标值。如果该城市名不存在,则提示用户重新输入。

[C程序]

int main() {

int city1,city2;

city1=GetCity("输入第1个城市名:");

city2=GetCity("输入第2个城市名:");

printf("%S和%s之间的距离为:%d km.\n”,cityTable[city1],

cityTable[city2],

kmTable[cityl][city2]);

return 0;

}

StatiC int GetCity(char * prompt) {

char * CityName;

int index;

cityName=(char *)malloc(20*sizeof(char));

while(TRUE){

printf("%S",prompt);

gets(cityName); /*获取输入字符串*/

index=FindCityInSortedArray(cityName);

if((1) ________ )break;

printf("城市名不存在,请重新输入。\n");

}

free(cityName);

return (2)__________;

}

Static int FindCityInSortedArray(char * key) {

int lh, rh, mid, cmp;

lh=0;

rh=NCities-1;

while((3)________){

mid=(1h+rh)/2;

cmp=strcmp((4)______ ); /*比较两个城市名是否相同*/

if(cmp==0)return (5)_______; /*两个城市名相同*/

if(cmp<0){rh=mid-1;)

else {lh=mid+1;)

}

return (-1); /*城市名不存在时返回-1 */

}

点击查看答案
第9题
请阅读以下技术说明和C代码,将程序段中(1)~(5)空缺处的语句填写完整。 【说明】 著名的四色定理指出

请阅读以下技术说明和C代码,将程序段中(1)~(5)空缺处的语句填写完整。

【说明】

著名的四色定理指出任何平面区域图均可用4种颜色着色,使相邻区域着不同的颜色。以下C程序对给定的区域图找出所有可能的不超过4种颜色的着色方案。该程序中用1~4分别表示4种颜色。要着色的N个区域用0~-1编号,区域相邻关系用adj[][]矩阵表示,矩阵的i行j列的元素为1,表示区域i与区域了相邻;矩阵的i行j列的元素为0,表示区域i与区域j不相邻。数组color[]用来存储着色结果,color[i]的值为区域i,所着颜色。

【C程序】

include <stdio.h>

define N 10

void output(int color[]) { /*输出一种着色方案*/

int i ;

for (i = 0 ; i < N ; i++ )

printf("%4d" , color[i] ) ;

printf ("\n") ;

}

int back(int *ip ,int color[] ) { /*回溯*/

intc = 4 ;

while (c == 4 ) {

if (*ip <= 0 )

return 0 ;

-- (*ip) ;

c =(1);

color[*ip] =-1 ;

}

return c ;

}

/*检查区域i,对c种颜色的可用性*/

int colorOk(int i , intc , int [] [N] ,int color[ ] ) {

int j ;

for (j = 0 ; j < i ; j++ )

if ((2) )

return 0 ;

return 1 ;

}

/*为区域i选一种可着色的颜色*/

int select (int i ,int c ,int adj [] [N] ,int color[ ] ){

int k ;

for(k = c ; k <= 4 ; k++ )

if(colorOK((3) ))

return k ;

return 0 ;

}

int coloring(int adj [] [N]) { /*寻找各种着色方案*/

int color[N] , i , c , cnt ;

for(i = 0 ; i < N ; i++)

color[i] =-1 ;

i = c = 0 ;

cnt = 0 ;

while(1) {

if((c =(4) ) == 0 {

c = back(&i , color);

if(c == 0 )

return cnt;

}

else {

(5);

i++ ;

if i == N) {

output(color);

++cnt ;

c = back(&i , color ) ;

}

else c = 0 ;

}

}

}

void main()(

int adj[N] [N] =

{ {0,1,0,1,1,1,1,1,1,1},

{1,0,1,1,0,1,1,1,1,0},

{0,1,0,1,0,1,1,0,1,1},

{1,1,1,0,1,1,0,0,1,1},

{1,0,0,1,0,1,0,0,0,0},

{1,1,1,1,1,0,1,0,0,1},

{1,1,1,0,0,1,0,0,1,0},

{1,1,0,0,0,0,0,0,1,1},

{1,1,1,1,0,0,1,1,0,1},

{1,0,1,1,0,1,0,1,1,0},

} ;

printf("共有%d组解.\n",coloring(adj));

}

点击查看答案
第10题
阅读以下应用说明及Visual Basic部分程序代码,将应填入(n)处的字句写在对应栏内。 【说明】本应用程

阅读以下应用说明及Visual Basic部分程序代码,将应填入(n)处的字句写在对应栏内。

【说明】

本应用程序是一个小写数字转换成大写格式的转换器,其运行窗口如图5所示。

阅读以下应用说明及Visual Basic部分程序代码,将应填入(n)处的字句写在对应栏内。 【说明

窗口中有两个标签(lblNumber和lblChinese)、两个文本框(txtNnmber和txtChinese)和一个命令按钮(cmdChange)。当单击按钮cmdChange时,将文本框txtNumber中数字转换成中文大写,并显示在文本框txtChinese中。例如,在文本框txtNumber输入0076845,单击cmdChange按钮,将在文本框txtChinese中显示“柒万陆仟捌佰肆拾伍”。

程序中调用的函数CChinse(Strdigit As String)的功能是先删除字符串的所有前导0,再调用函数Change(Strdigit As String),将数字字符串Strdigit转换成中文大写格式。

为了防止用户在文本框txtNumber输入非数字形式的字符,程序将以空字符代替所输入的非数字有形字符。

【程序】

Private Function Transfer(Strdigit As String)As String

′完成小写向大写的转换,这段代码省略

End Function

Private Function CChinese(Strdigit As String)As String

Dim intLen,intCounter As Integer

intLen = Len (Strdigit)

If intLen>0 Then

intcounter = 0

Do '过滤数字串Strdigit的前导0

intcounter = intcounter + 1

Loop Until Mid(Strdigit,(1))

intLen =(2)

Strdigit =(3) (Strdigit,intLen)

CChinese = Transfer(Strdigit)

End If

End Function

Private Sub cmdChange_Click()

txtChinese.Text=CChinese((4)) '调用Cchinese函数

End Sub

Private Sub txtNumber_KeyPress(KeyAscii As Integer)

Select Case KeyAscii '根据输入字符的ASCII码的值进行判断

Case KeyAscii<32 '保留输入的控制字符

Case 48 To 57 '保留输入的数字字符

Case Else '其他情况以空字符代替

(5)=0

End Select

End Sub

点击查看答案
退出 登录/注册
发送账号至手机
密码将被重置
获取验证码
发送
温馨提示
该问题答案仅针对搜题卡用户开放,请点击购买搜题卡。
马上购买搜题卡
我已购买搜题卡, 登录账号 继续查看答案
重置密码
确认修改