网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)

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

【程序说明】

本程序先从文件读人各考生的准考证号(设为整型数)及成绩,并将其存放在一棵检索二叉树上,二叉树结点的健值是成绩,每个结点带一链表,链表结点存放取得该成绩的考生的准考证号。然后,程序按中序遍历检索二叉树,从高分到低分输出结果,使每行输出成绩及其取得成绩的考生的准考证号。

【程序】

include < stdio. h >

typedef struet idnode {

int id;

struct idnode * next;

} ldNode;

typedef struct marknode I

int mark;

ldNode * head;

struct marknode * left, * right;

} MarkNode;

char fname [ ] = "sp07.dat";

main( )

{ int id, mark;

MarkNode * root = null;

FILE * fp = fopen(fname," r" );

if(!fp) {

printf("file%s open error, \n" , fname);

exit(0);

}

while (!feop(fp)) {

fscanf(fp," %d%d", &id, &mark);

btree(&root, id, mark);

}

fclose(fp);

print(root);

}

btree(MarkNod * * mpptr, int id, int mark)

{ ldNode * ip;

MarkNode *mp = * mpptr;

if (1) {

if (mark==p->mark) addldNODE ((2), id);

else if ( mark >mp -> mark) btree (&top -> left, id, mark);

else btree(&mp-> right, id, mark);

} else

Imp = ( marknode * ) malloc(sizeo (marknode) );

mp -> mark = mark;

mp -> left =mp -> right = NULL;

(3)

addldNode(&mp -> head, id);

(4);

}

}

addldNode(ldNode * * ipp, int id)

{ ldNode * ip = * ipp;

if ((5))addldNode ((6)), id;

else {

ip = (ldNode * )malloc(sizeof(ldNode) );

sp - > id = id;

ip -> next = NULL;

(7)

}

}

print(MarkNode * rap)

{ ldNode *ip, *ip0;

if (mp) {

print ( mp -> left);

printf(" %6d: \t" ,mp -> mark);

ip = mp -> head;

while(ip) {

printf(" %6d" ,ip -> id);

ip0 =ip;

ip = ip -> next;

free (ip0);

}

printf(" \n" ); printf( mp -> right); free(mp);

}

}


参考答案

更多 “ 阅读下列程序说明和C程序,将应填入程序中(n)处的字句,写在对应栏内。【程序说明】本程序先从文件读人各考生的准考证号(设为整型数)及成绩,并将其存放在一棵检索二叉树上,二叉树结点的健值是成绩,每个结点带一链表,链表结点存放取得该成绩的考生的准考证号。然后,程序按中序遍历检索二叉树,从高分到低分输出结果,使每行输出成绩及其取得成绩的考生的准考证号。【程序】include < stdio. h >typedef struet idnode {int id;struct idnode * next;} ldNode;typedef struct marknode Iint mark;ldNode * head;struct marknode * left, * right;} MarkNode;char fname [ ] = "sp07.dat";main( ){ int id, mark;MarkNode * root = null;FILE * fp = fopen(fname," r" );if(!fp) {printf("file%s open error, \n" , fname);exit(0);}while (!feop(fp)) {fscanf(fp," %d%d", id, mark);btree(root, id, mark);}fclose(fp);print(root);}btree(MarkNod * * mpptr, int id, int mark){ ldNode * ip;MarkNode *mp = * mpptr;if (1) {if (mark==p->mark) addldNODE ((2), id);else if ( mark >mp -> mark) btree (top -> left, id, mark);else btree(mp-> right, id, mark);} elseImp = ( marknode * ) malloc(sizeo (marknode) );mp -> mark = mark;mp -> left =mp -> right = NULL;(3)addldNode(mp -> head, id);(4);}}addldNode(ldNode * * ipp, int id){ ldNode * ip = * ipp;if ((5))addldNode ((6)), id;else {ip = (ldNode * )malloc(sizeof(ldNode) );sp - > id = id;ip -> next = NULL;(7)}}print(MarkNode * rap){ ldNode *ip, *ip0;if (mp) {print ( mp -> left);printf(" %6d: \t" ,mp -> mark);ip = mp -> head;while(ip) {printf(" %6d" ,ip -> id);ip0 =ip;ip = ip -> next;free (ip0);}printf(" \n" ); printf( mp -> right); free(mp);}} ” 相关考题
考题 阅读下列Java程序和程序说明,将应填入(n)处的字句写在对应栏内。【说明】StringEditor类的功能是:已知一个字符串,返回将字符串中的非字母字符都删除后的字符串。public (1) {public static String removeNonLetters( (2) ){StringBuffer aBuffer=(3);char aCharacter;for(int i=0; i<original.length();i++){aCharacter=(4);if(Character.isLetter(aCharacter))aBuffer.append( (5) );}return new String(aBuffer);}}public class StringEditorTester{public static void main(String args[]){String riginal="Hi!, My Name is Mark, 234I think you are my classmate?!!";System.out.println(StringEditor.removeNonLetters(original));}}

考题 阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。【C++程序】include include 阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。【C++程序】include < stdio. h >include < string. h >define Max 1000class Bank{int index;char date [Max] [10]; // 记录交易日iht amount[Max]; // 记录每次交易金额,以符号区分存钱和取钱int rest[ Max]; // 记录每次交易后余额static iht sum; // 账户累计余额public:Bank( ) {index =0;}void deposit( char d[ ] , int m) //存入交易{strcpy ( date [ index ], d);amount[ index] = m;(1);rest[ index] = sum;index++;}void withdraw (char d[ ], int m) //取出交易{strcpy( date[ index] ,d);(2);(3);rest[ index] = sum;index++;}void display( );};int Bank:: sum = 0;void Bank:: display ( ) //输出流水{int i;printf("日期 存入 取出 余额\n");for (4){printf(" %8s" ,date[i] );if (5)printf(" %6d" , -amount[i] );elseprintf( "%6d ",amount[i] );printf( "% 6d\n" ,rest[i] );} }void main( ){Bank object;object. deposit ( "2006.2.5", 1 00 );object. deposit( "2006.3.2" , 200);object. withdraw( "2006.4.1", 50);object. withdraw( "2006.4.5", 80);object. display ( );}本程序的执行结果如下:日期 存入 取出 余额 2006.2.5 100 1002006.3.2 200 3002006.4.1 50 2502006.4.5 80 170

考题 阅读以下说明和流程图,将应填入(n)处的字句写在对应栏内。【说明】已知头指针分别为La和lb的有序单链表,其数据元素都是按值非递减排列。现要归并La和Lb得到单链表Lc,使得Lc中的元素按值非递减排列。程序流程图如下所示:

考题 阅读以下说明及Visual Basic程序代码,将应填入(n)处的字句写在对应栏内。【说明】以下程序为求行列式X(5,5)的值S。【Visual Basic代码】Private Function col ( byval x ( 5,5 ) as integer ) as longdim fesult as longdim temp as longdim I as integerdim j as integerdim k as imegerresult = 0for I = to 5(1)for j = 1 to 5if I+j>6 thenk= ( 1+j ) mod 5elsek=1endiftemp=temp*x ( k,j )(2)result=(3)(4)(5)End function

考题 阅读以下函数说明和C语言函数,将应填入(n)处的字句写在对应栏内。【程序2.1说明】求所有满足如下条件的三位数:它除以11得的商等于它各位数字的平方和。例如 550,除以11商为50,50=52+52+02。【程序2.1】void main(){int i, j,n,s;for(i=100;i<=999;i++){n=i;j=n/11;s=0;while((1)){(2)n/=10;}if((3))printf("%d\t",i);}}【程序2.2说明】本程序输入一字符串,将其中的大写字母改变成小写字母。【程序2.2】void main(){int i=0;char s[120];scanf("%s",s);while((4)){if((5))s[i]=s[i]- 'A'+'a';i++;}printf("%s\n",s);}

考题 阅读下列程序说明和C++程序,把应填入其中(n)处的字句,写在对应栏内。【说明】阅读下面几段C++程序回答相应问题。比较下面两段程序的优缺点。①for (i=0; i<N; i++ ){if (condition)//DoSomething…else//DoOtherthing…}②if (condition) {for (i =0; i<N; i++ )//DoSomething}else {for (i=0; i <N; i++ )//DoOtherthing…}

考题 阅读下列程序说明和C程序,将应填入(n)处的字句写在对应栏内。[函数2.1说明]下面程序的功能是计算x和y的最小公倍数。[函数2.1]main(){ int m,n,d,r;seanf("%d %d",m,n);if(m<n) {r=m;m=n;n=r;}(1);while (d%n! =0) (2);printf("%d\n",d);}[函数2.2说明]下述程序接收键盘输入,直到句点“.”时结束。输入的字符被原样输出,但连续的空格输入将转换成一个空格。[函数2.2]include <stdio.h>main(){ char c,preChar='\0';c = getchar();while(c! = '.'){if((3)) putchar(c);else if(preChar! =' ') putchar(c);(4);c=(5);}}

考题 ●试题二阅读下列函数说明和C代码,将应填入(n)处的字句写在答题纸的对应栏内。【说明】该程序运行后,输出下面的数字金字塔【程序】includestdio.hmain (){char max,next;int i;for(max=′1′;max=′9′;max++){for(i=1;i=20- (1) ;++i)printf(" ");for(next= (2) ;next= (3) ;next++)printf("%c",next);for(next= (4) ;next= (5) ;next--)printf("%c",next);printf("\n");}}

考题 试题三(共 15 分)阅读以下说明和 C 程序,将应填入 (n) 处的字句写在答题纸的对应栏内。

考题 ()阅读下列说明和C语言程序,将应填入 (n)处的语句写在答题纸的对应栏内。[说明]下面程序是一个带参数的主函数,其功能是显示在命令行中输入的文本文件内容。[C语言函数]#include"stdio.h"main(argc,argv) int argc; char *argv[]; { (1) ; if((fp=fopen(argv[1],”r’’))== (2) ) { printf(”file not open!\n”);exit(0);} while( (3) ) putchar( (4) ); (5); }