




版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、一、填空題1.對(duì)下列二叉樹進(jìn)行中序遍歷的結(jié)果是 dbxeayfzc 。 2.按照軟件測(cè)試的一般步驟,集成測(cè)試應(yīng)在 單元 測(cè)試之后進(jìn)行。3.軟件工程三要素包括方法、工具和過(guò)程,其中, 過(guò)程 支持軟件開發(fā)的各個(gè)環(huán)節(jié)的控制和管理。4.數(shù)據(jù)庫(kù)設(shè)計(jì)包括概念設(shè)計(jì)、 邏輯設(shè)計(jì) 和物理設(shè)計(jì)。5.在二維表中,元組的 分量 不能再分成更小的數(shù)據(jù)項(xiàng)。6.設(shè)變量a和b已正確定義并賦初值。請(qǐng)寫出與a-=a+b等價(jià)的賦值表達(dá)式 a=-b 。7.若整型變量a和b中的值分別為7和9,要求按以下格式輸出a和b的值:a=7b=9請(qǐng)完成輸出語(yǔ)句printf( a=%dnb=%dn ,a,b);8.以下程序的輸出結(jié)果是 1 。#in
2、clude main() int i,j,sum;for(i=3;i=1;i-) sum=0;for(j=1;j=i;j+) sum+=i*j;printf(%dn,sum);9.以下程序的輸出結(jié)果是 9911 。#include main() int j,a=1,3,5,7,9,11,13,15,*p=a+5;for(j=3;j;j-) switch(j) case 1:case 2: printf(%d,*p+); break;case 3: printf(%d,*(-p);解:和for(j = 3; j != 0; j-)是一樣的的意思。因?yàn)樵赾語(yǔ)言中的邏輯運(yùn)算中,0 與 j!=0 的結(jié)
3、果都是false。循環(huán)從3開始,每次j減1,當(dāng)j=0時(shí),循環(huán)條件不滿足,因此只巡檢3次;這種寫法很不好,不推薦使用。10.以下程序的輸出結(jié)果是 3 。#include #define n 5int fun(int *s,int a,int n) int j;*s=a;j=n;while(a!=sj)j-;return j;main() int sn+1; int k;for(k=1;k=n;k+) sk=k+1;printf(%dn,fun(s,4,n);11.以下程序的輸出結(jié)果是 15 。#includeint fun(int x) static int t=0; return(t+=x);
4、main() int s,i; for(i=1;i=5;i+) s=fun(i); printf(%dn,s);12.以下程序按下面指定的數(shù)據(jù)給x數(shù)組的下三角置數(shù),并按如下形式輸出,請(qǐng)?zhí)羁铡?3 72 6 91 5 8 10#includemain() int x44,n=0,i,j; for(j=0;j=j; i- ) n+;xij= n ; for(i=0;i4;i+) for(j=0;j=i;j+) printf(%3d,xij); print(n);13.以下程序的功能是:通過(guò)函數(shù)func輸入字符并統(tǒng)計(jì)字符的個(gè)數(shù)。輸入時(shí)用字符作為輸入結(jié)束標(biāo)志。請(qǐng)?zhí)羁铡?includelong func
5、( ); /* 函數(shù)說(shuō)明語(yǔ)句 */main() long n; n=func( ); printf(n=%ldn,n);long func() long m; for(m=0;getchar()!=; m+ ); return m;答題處,請(qǐng)把以上各小題的答案填寫如下:1. dbxeayfzc 2. 單元 3. 過(guò)程 4. 邏輯設(shè)計(jì) 5. 分量 6. a=-b 7. a=%dnb=%dn 8. 1 9. 9911 10. 3 11. 15 12. i- 、 n 13. func( ) 、 m+ 二、填空題1測(cè)試用例包括輸入值集和 輸出 值集。 2深度為5的滿二叉樹有 16 個(gè)葉子結(jié)點(diǎn)。 3設(shè)某
6、循環(huán)隊(duì)列的容量為50,頭指針front=5(指向隊(duì)頭元素的前一位置),尾指針rear=29(指向隊(duì)尾元素),則該循環(huán)隊(duì)列中共有 24 個(gè)元素。 4在關(guān)系數(shù)據(jù)庫(kù)中,用來(lái)表示實(shí)體之間聯(lián)系的是 關(guān)系 。 5 在數(shù)據(jù)庫(kù)管理系統(tǒng)提供的數(shù)據(jù)定義語(yǔ)言、數(shù)據(jù)操縱語(yǔ)言和數(shù)據(jù)控制語(yǔ)言中, 數(shù)據(jù)定義語(yǔ)言 負(fù)責(zé)數(shù)據(jù)的模式定義與數(shù)據(jù)的物理存取構(gòu)建。 6已有定義:char c=;int a=1,b;(此處c的初值為空格字符),執(zhí)行b=!c&a;后b的值為 0 。解析:b=(!c)&a7設(shè)變量已正確定義為整型,則表達(dá)式n=i=2,+i,i+的值為 3 。 8若有定義:int k;,以下程序段的輸出結(jié)果是 #2#4 。 fo
7、r(k=2;k6;k+,k+) printf(“#%d”,k); 9以下程序段的定義語(yǔ)句中,x1的初值是 2 ,程序運(yùn)行后輸出的內(nèi)容是 2468 。 #include main() int x=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,*p4,i; for(i=0;i4;i+) pi=&x2*i+1; printf(“%d ”,pi0); printf(“n”); 10以下程序的輸出結(jié)果是 35 。 #include void swap(int *a,int *b) int *t; t=a; a=b; b=t; main() int i=3,j=5,*p=&
8、i,*q=&j; swap(p,q); printf(“%d %dn”,*p,*q); 11以下程序的輸出結(jié)果是 4 。 #include main() int a5=2,4,6,8,10, *p; p=a; p+; printf(“%d”,*p); 12以下程序的輸出結(jié)果是 13 。 #include void fun(int x) if(x/20) fun(x/2); printf(“%d ”,x); main() fun(3); printf(“n”); 13以下程序中函數(shù)fun的功能是:統(tǒng)計(jì)person所指結(jié)構(gòu)體數(shù)組中所有性別(sex)為m的記錄的個(gè)數(shù),存入變量n中,并做為函數(shù)值返回。
9、請(qǐng)?zhí)羁眨?#include #define n 3 typedef struct int num;char nam10; char sex; ss; int fun(ss person ) int i,n=0; for(i=0;in;i+) if( personi.sex =m ) n+; return n; main() ss wn=1,”aa”,f,2,”bb”,m,3,”cc”,m; int n; n=fun(w); printf(“n=%dn”,n); 14以下程序從名為filea.dat的文本文件中逐個(gè)讀入字符并顯示在屏幕上。請(qǐng)?zhí)羁眨?#include main() file *fp
10、; char ch; fp=fopen( ”filea.dat”,”r” ); ch=fgetc(fp); whlie(!feof(fp) putchar(ch); ch=fgetc(fp); putchar(n); fclose(fp); 答題處,請(qǐng)把以上各小題的答案填寫如下:1. 輸出 2. 16 3. 24 4. 關(guān)系 5. 數(shù)據(jù)定義語(yǔ)言 6. 0 7. 3 8. #2#4 9. 2 、 2468 10. 35 11. 4 12. 13 13. personi.sex 14. ”filea.dat”,”r” 三、選擇題:12345678910aabadbacec1以下程序運(yùn)行后的輸出結(jié)果
11、是 a 。#include #include main( ) int * a, * bt * c;a = b = c = ( int * ) malloc( sizeof( int) ) ;* a=l;* b = 2;*c = 3;a = b;printf(“%d,%d,%dn”,*a,*b,*c);a) 3,3, 3 b)2,2, 3 c) 1,2, 3 d) 1, 1,32以下關(guān)于typedef的敘述中錯(cuò)誤的是 a 。a)用typedef可以增加新類型b) typedef只是將已存在的類型用一個(gè)新的名字來(lái)代表c)用typedef可以為各種類型說(shuō)明一個(gè)新名,但不能用來(lái)為變量說(shuō)明一個(gè)新名d)用
12、typedef為類型說(shuō)明一個(gè)新名,通常可以增加程序的可讀性3. 若有以下程序段 b 。typedef struct s int g; char h; t;以下敘述中正確的是a) 可用s定義結(jié)構(gòu)體變量b) 可用t定義結(jié)構(gòu)體變量c) s是struct類型的變量d) 34. 以下結(jié)構(gòu)體類型說(shuō)明和變量定義中正確的是 a 。a) typedef structint n;char c; rec;rec t1,t2;b)struct rec;int n;char c;rec t1,t2;c)typedef struct rec;int n=0;char c=a; t1,t2;rec t1,t2;d) str
13、uctint n;char c; rec ;5. 有以下定義和語(yǔ)句struct workersint num;char name20;char c;structint day;int month;int year; s;struct workers w,*pw;pw=&w;能給w中year成員賦1980的語(yǔ)句是 d 。a)* pw.year = 1980;b)w. year =1980;c)pw-year= 1980;d)w. s. year = 1980;6以下程序運(yùn)行后的輸出結(jié)果是 b 。#include struct ord int x,y; dt2 = 1 ,2,3,4;main()s
14、truct ord * p = dt;printf( %d, +p-x);printf(%d, +p-y);a) 1, 2 b)2,3 c)3,4 d)4,17. 以下程序的運(yùn)行結(jié)果是 a 。#include #include typedef struct char name9; char sex; float score2;stu;void f(stu a)stu b=“zhao”,m,85.0,90.0; int i;strcpy(,);a. sex=b.sex;for( i=0;i2;i+) a.scorei=b.scorei;main( )stu c= “qia
15、n”,f,95.0,92.0;f(c);printf( “%s,%c,%2.0f,%2.0fn”,,c.sex,c.score0,c.score1);a)qian,f,95,92 b)qian,m,85,90c)zhao,f,95,92d)zhao,m,85,90解析:結(jié)構(gòu)體作為函數(shù)參數(shù)時(shí)是傳值調(diào)用。8. 以下程序的運(yùn)行結(jié)果是 c 。#include #include typedef struct char name9; char sex; float score2;stu;stu f(stu a)stu b=“zhao”,m,85.0,90.0; int i;strcpy(a.n
16、ame,);a. sex=b.sex;for(i=0;i,2;i+) a.scorei=b.scorei;return a;main( )stu c=“qian”,f,95.0,92,0,d;d=f( c );printf( “%s,%c,%2.0f,%2.0fn”,,d.sex,d.score0,d.score1);a)qian, f, 95, 92 b) qian, 85, 90c)zhao, m, 85, 90 d) zhao, f, 95, 929. 以下程序運(yùn)行后的輸出結(jié)果是 e 。#include struct s int n; int a20;void f
17、(struct s *p) int i,j,t;for(i=0;in-1;i+)for(j=i+1;jn-1;j+)if(p-aip-aj)t=p-ai;p-ai=p-aj;p-aj=t;main( )int i;struct s s=10,2,3,1,6,8,7,5,4,10,9;f(&s);for(i=0;is.n;i+) printf(“%d”,s.ai);a) 12345678910 b) 10987654321 c) 23168754109 d) 987612345 e)12345678109解析:數(shù)組部分元素采用冒泡排序法進(jìn)行升序排序。10.有以下程序段,描述正確的是: c typ
18、edef struct nodeint data;struct node *next; *node;node p;a) p是指向struct node結(jié)構(gòu)體變量的指針的指針。b) node p;語(yǔ)句出錯(cuò)c) p是指向struct node結(jié)構(gòu)體變量的指針d) p是struct node結(jié)構(gòu)體變量四、程序填空題1. 用選擇法對(duì)10個(gè)整數(shù)排序。#include int main( )int i,j,min,temp,a11;printf(“enter data:n”);for (i=1 ; i=10 ; i+)printf(“a%d=”,i);scanf(“%d”, &ai );printf(“n
19、”);printf(“the orginal numbers:n”);for (i=1;i=10;i+)printf(“%5d”, ai );printf(“n”);for (i=1; i=9 ;i+)min=i;for ( j=i+1 ;jaj) min=j;temp=ai;ai= amin ;amin=temp;printf(“nthe sorted numbers:n”);for (i=1;i=10;i+)printf(“%5d”,ai);printf(“n”);return 0;四、分析題敘述下列各程序段的功能,按授課的思路給關(guān)鍵語(yǔ)句加注釋。#include #include #def
20、ine len sizeof(struct student)struct studentlong num;float score;struct student *next;int n;int main( )struct student student * creat( );/函數(shù)聲明struct student student *del(student *,long); /函數(shù)聲明struct student student *insert(student *,student *);/函數(shù)聲明void print(student *);/函數(shù)聲明struct student *head,*st
21、u;long del_num;printf(“input records:n”); /提示輸入head=creat( );/建立鏈表,返回頭指針print(head);/輸出全部結(jié)點(diǎn)printf(“ninput the deleted number:”);/提示用戶輸入要?jiǎng)h除的結(jié)點(diǎn)scanf(“%ld”,&del_num);/輸入要?jiǎng)h除的學(xué)號(hào)while(del_num !=0)/當(dāng)輸入的學(xué)號(hào)為0時(shí)結(jié)束循環(huán)head=del(head,del_num);/刪除結(jié)點(diǎn)后返回鏈表的頭地址print(head);/輸出全部結(jié)點(diǎn)printf(“input the deleted number:”);/*提示
22、用戶輸入要?jiǎng)h除的結(jié)點(diǎn)*/scanf(“%ld”,&del_num);/輸入要?jiǎng)h除的學(xué)號(hào)printf(“ninput the inserted record:”);/提示輸入要插入的結(jié)點(diǎn)stu=(struct student *)malloc(len);/開辟一個(gè)新結(jié)點(diǎn)scanf(“l(fā)d,%f ”,&stu-num,&stu-score);/輸入要插入的結(jié)點(diǎn)while(stu-num !=0)/當(dāng)要輸入的學(xué)號(hào)為零時(shí)結(jié)束循環(huán)head=insert(head,stu);/返回鏈表的頭地址,賦給headprint(head);/輸出全部結(jié)點(diǎn)printf(“input the inserted reco
23、rd:”);/*請(qǐng)用戶輸入要插入的結(jié)點(diǎn)*/stu=(struct student *)malloc(len);/開辟一個(gè)新結(jié)點(diǎn)scanf(“%ld,%f ”,&stu-num,&stu-score);/輸入插入結(jié)點(diǎn)的數(shù)據(jù)return 0;/建立鏈表的函數(shù)creat( )struct student * creat( )struct student * head;struct student * p1,* p2;n=0;p1=p2=(struct student *)malloc(len);scanf(“%ld,%f “,&p1-num,&p1-score);head=null;while(p1
24、-num !=0)n=n+1;if(n=1)head=p1;else p2-next=p1;p2=p1;p1=(struct student *)malloc(len);scanf(“%ld,%f “,&p1-num,&p1-score);p2-next=null;return(head);/刪除鏈表中結(jié)點(diǎn)的函數(shù)del(struct student * head,long num )struct student * del(struct student * head,long num)struct student * p1, * p2;if(head=null)/若是空表printf(“nli
25、st null ! n”);return(head) ;p1=head;/使p1指向第1個(gè)結(jié)點(diǎn)while(num !=p1-num & p1-next !=null)/p1指向的不是所要找的結(jié)點(diǎn)且后面還有結(jié)點(diǎn)p2=p1 ; p1=p1-next;/p1后移一個(gè)結(jié)點(diǎn)if(num=p1-num)/找到了 if(p1=head)head=p1-next;/*若p1指向的是首結(jié)點(diǎn),把第2個(gè)結(jié)點(diǎn)地址賦予head*/else p2-next=p1-next;/否則將下一結(jié)點(diǎn)地址賦給前一結(jié)點(diǎn)地址printf(“delete:%ldn”,num);n=n-1;elseprintf(“%ld not been
26、found! n”,num);/找不到該結(jié)點(diǎn)return(head); /插入結(jié)點(diǎn)的函數(shù)insert(struct student *head,struct student *stud)struct student * insert(struct student * head,struct student * stud)struct student * p0,* p1,* p2;p1=head;/使p1指向第一個(gè)結(jié)點(diǎn)p0=stud;/指向要插入的結(jié)點(diǎn)if(head=null)/原來(lái)的鏈表是空表head=p0; p0-next=null;/使p0指向的結(jié)點(diǎn)作為頭結(jié)點(diǎn)elsewhile(p0-nu
27、m p1-num) & (p1-next !=null)p2=p1;/使p2指向剛才p1指向的結(jié)點(diǎn)p1=p1-next;/p1后移一個(gè)結(jié)點(diǎn)if(p0-num num)if(head=p1) head=p0;/插到原來(lái)第1個(gè)結(jié)點(diǎn)之前else p2-next=p0;/插到p2指向的結(jié)點(diǎn)之后p0-next=p1;elsep1-next=p0;p0-next=null;/插到最后的結(jié)點(diǎn)之后n=n+1;/結(jié)點(diǎn)數(shù)加1return(head);/輸出鏈表的函數(shù)print( )void print(struct student * head)struct student * p;printf(“nnow, t
28、here %d records are:n”,n);p=head;if(head !=null)doprintf(“%ld %5.1fn “,p-num,p-score);p=p-next;while(p !=null);答:以上5個(gè)函數(shù)組成一個(gè)程序,實(shí)現(xiàn)鏈表的建立、輸出、刪除和插入。在主函數(shù)中指定需要?jiǎng)h除和插入的結(jié)點(diǎn)。定義stu為指針變量,在需要插入時(shí)先用malloc開辟一個(gè)內(nèi)在區(qū),將其起始地址賦給stu,然后輸入此結(jié)構(gòu)變量中各成員的值。對(duì)不同的插入對(duì)象,stu的值是不同的,每次指向一個(gè)新的student變量。在調(diào)用insert函數(shù)時(shí),實(shí)參為head和stu,將已有的鏈表起始地址傳給inse
29、rt函數(shù)的參形head,將新開辟的單元的地址stu傳給形參stud,返回的函數(shù)值是經(jīng)過(guò)插入之后的鏈表的頭指針(地址)。五、選擇題12345678910ccbbdcdadd1.以下程序運(yùn)行的結(jié)果是 c 。#include #include int fun( int n)int *p;p=(int *)malloc(sizeof(int);*p = n;return *p;main() int a;a=fun(10);printf(%dn,a+fun(10);a) 0 b) 10 c) 20 d)出錯(cuò)2. 有以下語(yǔ)句:typedef struct ttchar c;int a4 ; cin;則下列
30、敘述中正確的是 c 。a)可以用tt定義結(jié)構(gòu)體變量 b)tt是struct類型的變量c)可以用cin定義結(jié)構(gòu)體變量 d)cin是stmcttt類型的變量3.下面結(jié)構(gòu)體的定義語(yǔ)句中,錯(cuò)誤的是 b 。a) struct ord int x;int y;int z; struct ord a;b)struct ord int x;int y;int z;struct ord a;c) struct ord int x;int y;int z; a;d) struct int x;int y;int z; a;4. 設(shè)有定義struct complex int real,unreal; datal =
31、 1 ,8 ,data2;則以下賦值語(yǔ)句中錯(cuò)誤的是 b 。a) data2 = data1 ;b) data2 = (2, 6);c) data2. real = data1. real;d) data2. real = data1. unreal;5.有以下程序#include #include struct a int a;char b10 ;doublec;struct a f( struct a t) ;main( ) struct a a = 1001,zhangda,1098.01 ;a= f( a) ;printf(%d,%s,%6.1fn,a.a,a.b,a.c);struct
32、 a f( struct a t) t.a=1002;strcpy(t.b,changrong);t.c=1202.0;return t; 程序運(yùn)行后的輸出結(jié)果是 d 。a)1001 ,zhangda, 1098.0b) 1002, zhangda,1202.0c)1001,changrong,1098.0d)1002, changrong,1202.06. 以下程序運(yùn)行的結(jié)果是 c 。#include struct stint x,y; data2=1,10,2,20;main( )st *p=data;printf(%d,p-y); printf(%dn,(+p)-x);a) 10,1 b)20,1 c)10,2 d)20,27. 以下程序運(yùn)行后的輸出結(jié)果是 d 。#include typedef struct int b,p; a;void f(a c)/*注意:c是結(jié)構(gòu)變量名*/int j;c.
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 化工分離企業(yè)管理制度
- 培訓(xùn)帶班班任管理制度
- 小吃培訓(xùn)餐飲管理制度
- 售樓中心保潔管理制度
- 商務(wù)咨詢公司管理制度
- 口腔醫(yī)療投訴管理制度
- 化工專業(yè)車間管理制度
- 培訓(xùn)課堂教學(xué)管理制度
- 公司淘寶美工管理制度
- 農(nóng)村裝修日常管理制度
- 軟件專業(yè)畢業(yè)設(shè)計(jì)
- 安徽合肥包河區(qū)演藝集團(tuán)有限責(zé)任公司招聘筆試題庫(kù)2025
- 湖北省武漢市江夏區(qū)2025屆九年級(jí)下學(xué)期5月月考語(yǔ)文試卷(含答案)
- 雨棚翻新合同協(xié)議書范文
- 2025年湖南省永州市寧遠(yuǎn)縣中考三模歷史試題(含答案)
- 2024年江蘇省無(wú)錫市中考?xì)v史真題(解析版)
- 消防安全知識(shí)培訓(xùn)試題及答案
- 閱讀策略在小學(xué)英語(yǔ)教學(xué)中的應(yīng)用
- 2025年黃山旅游發(fā)展股份有限公司春季招聘75人筆試參考題庫(kù)附帶答案詳解
- 2025年中考時(shí)事政治題及答案
- 物流運(yùn)輸及配送服務(wù)方案投標(biāo)文件(技術(shù)方案)
評(píng)論
0/150
提交評(píng)論