第一篇:c語言課后答案
第7章
數(shù)組習(xí)題解答
一、在以下每一題的四個選項中,請選擇一個正確的答案。【題7.1】 C 【題7.2】 D 【題7.3】 D 【題7.4】 D 【題7.5】 C 【題7.6】 C 【題7.7】 C 【題7.8】 C 【題7.9】 B 【題7.10】 B
二、判斷下列各敘述的正確性,若正確在()內(nèi)標(biāo)記√,若錯誤在(【題7.11】 √ 【題7.12】 √ 【題7.13】 × 【題7.14】 × 【題7.15】 √ 【題7.16】 × 【題7.17】 × 【題7.18】 × 【題7.19】 √ 【題7.20】 ×
三、填空。請在下面各敘述的空白處填入合適的內(nèi)容?!绢}7.21】 字符數(shù)組 【題7.22】 0 【題7.23】 4 【題7.24】 按行的順序存放 【題7.25】 48 【題7.26】 strcat()【題7.27】 6 【題7.28】 10 【題7.29】 strcmp()
×。– 1 –)內(nèi)標(biāo)記 C語言程序設(shè)計教程實驗指導(dǎo)與習(xí)題解答
【題7.30】 #include
四、閱讀下面的程序,寫出程序運行結(jié)果。【題7.31】 abcdefg
abcdef
abcde
abcd
abc
ab
a 【題7.32】 1 1
1
1
1 【題7.33】 a[2]*b[1]=2
a[4]*b[4]=16
a[6]*b[7]=42 【題7.34】 10 1 2 3 4 5 6 7 8 9
五、程序填空。請在下面程序空白處填入合適的語句?!绢}7.35】 a[j++]=a[i] 【題7.36】 array[i]>array[j]
六、編程。對下面的問題編寫程序并上機驗證。
【題7.37】 編寫程序,用冒泡法對20個整數(shù)排序(按升序排序)。
/*lx7_1.c*/ #include “stdio.h” #define N 20 void main(){
int data[N];
int i,j,t;
printf(“請輸入 %d 個整數(shù):n”,N);
for(i=0;i scanf(“%d”,&data[i]); printf(“n”); for(i=0;i for(j=0;j if(data[i]>data[j]) { t=data[i];data[i]=data[j];data[j]=t;} – 2 – 第一部分習(xí)題解答 printf(“排序后的輸出為:n”); for(i=0;i printf(“%d ”,data[i]);} 【題7.38】 編寫程序,將一個數(shù)插入到有序的數(shù)列中去,插入后的數(shù)列仍然有序。 /*lx7_2.c*/ #include “stdio.h” #define N 5 void main(){ int a[N+1]; int i,j,t,num; printf(“請輸入 %d 個整數(shù):n”,N); for(i=0;i scanf(“%d”,&a[i]); printf(“n”);