【正文】
________。 d+=p++。 d+=a++。} int main() { int x=2,y=5,z=8,r。 C++語言中,形參的缺省存儲類型是 __________。 statc int c=3。 for(i=0。 } C++語言中,函數(shù)的隱含存儲類型是 __________。 int f(int a) { int b=0。 } int main() { int a=2,i。 coutendl。 double val。 } void function(double val) {val=3。 coutk” ” 。 } ,錯誤的是 __________。 include iostream using namespace std。k=n。 include iostream using namespace std。 f(a,b,c)。 int ff(int n) { static int f=1。 for(i=1。 double fun(double x,int y) { int i。i++) z=z*____________________。 void fun() { static int a=0。 for(cc=1。 } __________。 else s=n+sum(n1)。 coutxendl。 couti’ \t’ j’ \t’ kendl。 } couti’ \t’ j’ \t’ kendl。 for(int k=1。 x++。 //文件 1: include iostream using namespace std。 c=max(a,b)。 return z。 int main() { void test(int char,double__________) test(1,’ A’ ,)。} _______________時,該函數(shù)就聲明為內(nèi)聯(lián)函數(shù)。 第 19 頁 共 27 頁 習題五(用戶自定義數(shù)據(jù)類型) 一、選擇題 int型變量占 4字節(jié)的存儲單元,若有定義 int x[10]={0,2,4}。 char s[]=” \” abcd\\England\” \n” 。 char y[]={’ a’ ,’ b’ ,’ c’ ,’ d’ ,’ e’ ,’ f’ ,’ g’ }。 str1復制到串 str2中后再連接到串 str3之后 str1連接到串 str2之后再復制到串 str3之后 str2復制到串 str1中后再將串 str3連接到串 str1之后 str2連接到串 str1之后再將串 str1復制到串 str3中 ,能打印出字母 M的語句是 _________。 class[3].nameendl。 _________。 enum team {my,your=4,his,her=his+10}。 {double a。 }s。 char b[10]。 char a[15]=” windows9x” ;,則執(zhí)行語句 couta+8;后的輸出結(jié)果是 _________。(注意:不得使用逗號表達式) while(s[i]) { d[j]=_______________。 include iostream using namespace std。 for(i=0,j=strlen(str)。 str[j1]=m。 include iostream using namespace std。 for(i=0。 【 1】 ) if( 【 2】 ) {t=a[i]。 coutendl。 double ave。 for(i=9。 } 2. include iostream using namespace std。 int main() { int a[3][3]={{1,2},{3,4},{5,6}},i,j,s=0。j=i。 int main() { char w[][10]={“ ABCD” ,” EFGH” ,” IJKL” ,” MNOP” }。 } 5. include iostream using namespace std。ch[i]=’ 0’ amp。 s+=a[i][j]。int y。 struct abc {int a。 int main() { struct abc s[2]={{1,2,3},{4,5,6}} int i。 int main() { char b[]=” Hello,you” 。該程序有錯誤,請將程序修改正確(只能對有錯誤的行進行修改,不得修改正確的行,也不得刪除或增加程序行) include iostream using namespace std。i=3。 cout” sum=” sumendl。 第 23 頁 共 27 頁 int main() { struct stu {int n。 float av=。 cina[k]。 for(k=1。 。 p=amp。 : int i,j=2,*p=amp。j =amp。 A. B. C. D. _________。 A. B. C. D. _________。 A. B. C. D. _________。 A. B. C. D. _________。 A. B. C. D. _________。 A. B. C. D. _________。 a=1, b=2, c=3, d=4,則條件表達式 ab?a:cd?c:d的值為 ______________。 ; ; ,參數(shù)類型不同; , ______是錯誤的。a39。 float x。 case :cout**\n。 case 1+2:cout**\n。下列 switch語句中, _____是正確的。break。 case 3,4:++b。 } break語句的描述中, ______是不正確的。amp。 do? while循環(huán)的循環(huán)次數(shù)為 ________。 }while(i)。i++,j) ++語言中規(guī)定函數(shù)的返回值的類型 是由 _______。 ; ,應該是先設置右邊的再 設置左邊的; ,應該全部參數(shù)都設置 ________。k=0。 case 0: case 5:s+=2。 } 函數(shù)的遞歸調(diào)用例: include iostream include iomanip using namespace std。i++) coutsetw(3)i。 return 0。 } } int main() { print(4)。 for(int i=1。 } } cout” s=” sendl。break。 int main() { int s=0,k。 在此函數(shù)調(diào)用語句中實參的個數(shù)是 ________。 for(int i=0,j=10。 do{ coutiendl。i++) while循環(huán)的次數(shù)是 _______。 for(int i=0,x=0。break。break。break。 case 2:cout**\n。 case 3:cout**\n。則正確的 switch語句是 ______。 18/4*sqrt()/5的值的數(shù)據(jù)類型是 ______。OK!\39。 switch語句的描述中, ______是正確的。 A. B. C. D. _________。 A. B. C. D. _________。 A. B. C. D. _________。 A. B. C. D. _________。 A. B. C. D. _________。 A. B. C. D. _________。 A. B. C. D. _________。則能完成 i=j賦值功能的語句是 _________。*p=10。 第 24 頁 共 27 頁 習題六(指針和引用) 一、選擇題 , a的值是 _________。k++) if(a[k].c=av) couta[k]endl。} av=av/5。k=5。}a[6]。該程序有錯誤,請將程序修改正確。j=3。 int sum=0。 coutbendl。 couttendl。int c。 coutum[0].y/um[0].x*xnum[1].xendl。 } 6. include iostream using namespace std。ch[i]=’ 9’ 。 int i,s=0。k3。 coutsendl。i3。 couta[0][3]a[1][2]a[2][1]a[3][0]endl。i) a[i]=10i。 三、閱讀程序題 指出下列程序的運行結(jié)果 1. include iostream using namespace std。 第 21 頁 共 27 頁 struct stud { char num[6]。a[j]=t。i+=2) for(j=i+2。 int i,j,k。 } :將字符數(shù)組 a中下標值為偶數(shù)的元素從小到大排列,其他元素不變。i++,j) { m=str[i]。 int i,j。 } d[j]=0。int j=0,i=0。 ABC a。 {double a。 char b[10]。 ,能定義 s為合法的結(jié)構(gòu)變量的是 _________。 則枚舉常量 a1和 a3的值分別是 _________。 class[2].name[1]endl。int age。 x和數(shù)組 y等價 x和數(shù)組 y的長度相同 x的長度大于數(shù)組 y的長度 x的長度小于數(shù)組 y的長度 strcmp(“ box” ,” boss” )的值是 _________。 x正確進行初始化的語句是 _________。 ,錯誤的是 _________。 500到 600之間能被 7整 除的數(shù)之和、 800到 900之間能被 3整除的數(shù)之和。 return 0。//定義靜態(tài)局部變量 a、 b 1, A, 2,B, 請將程序補充完整。 } //文件 2: int max(int x,int y) { int z。//定義全局變量 a、 b extern int max(int x,int y)。 cout” m=” m’ \t’ ” n=” nendl。k++) { 第 18 頁 共 27 頁 int m=0,n=0。 include iostream using n