【正文】
MOV R7, 50 DELA1: MOV R6, 100 DJNZ R6, $ DJNZ R7, DELA1 RET 42 。******顯示子程序 ****** DISP: MOV DPTR,TAB1 MOV A,32H MOVC A,@A+DPTR MOV P1,A RET 。******0~ 9及熄滅符段碼表 ****** TAB1:DB 0C0H, 0F9H, 0A4H, 0B0H, 99H, 92H DB 82H, 0F8H, 80H, 90H, 0FFH END 43 int a[3]。 a[0]=0。 a[1]=1。 a[2]=2。 int *p, *q。 p=a。 q=amp。a[2]。 cout a[qp] 39。\n39。 下面程序運(yùn)行結(jié)果 ? 答案: 2 int *ptr。 ptr=(int *)0x8000。 *ptr=oxaabb。 答案:會(huì)導(dǎo)致運(yùn)行錯(cuò)誤 , 因?yàn)檫@種做法會(huì)給一個(gè)指針?lè)峙湟粋€(gè)隨意的地址 , 這是非常危險(xiǎn)的 。 不管這個(gè)指針有沒(méi)有被使用過(guò) , 這么做都是不允許的 。 what results after run the following code? 44 what will happen after running the “Test”? 答案:程序崩潰 。 因?yàn)?GetMemory并不能傳遞動(dòng)態(tài)內(nèi)存 , 函數(shù)里的 str值一直都是 NULL。 include iostream void GetMemory(char *p, int num) { p=(char *)malloc(sizeof(char) *num)。 }。 int main() { char *str = NULL。 GetMemory(str, 100)。 strcpy(str,hello)。 return 0。 } 45 下列程序輸出結(jié)果 ? 答案: C include iostream using namespace std。 class A { public: int _a。 A() { _a=1。 } void print() { printf(%d, _a)。 } }。 class B : public A { public: int _a。 B() { _a=2。 } }。 int main() { B b。 ()。 printf(%d,)。 } A 22 B 11 C 12 D 21 46 A 函數(shù)的形參在函數(shù)未調(diào)用時(shí)預(yù)分配存儲(chǔ)空間 B 若函數(shù)的定義出現(xiàn)在主函數(shù)之前 , 則可以不必再說(shuō)明 C 若一個(gè)函數(shù)沒(méi)有 return語(yǔ)句 , 則什么都不返回 D 一般來(lái)說(shuō) , 函數(shù)的形參和實(shí)參的類(lèi)型應(yīng)該一致 以下描述正確的是 ? 答案: D 47 一個(gè)指向整型數(shù)組的指針的定義為 ( ) A int (*ptr)[] B int *ptr[] C int *(ptr[]) D int ptr[] 答案: A 48 struct S{ int i。 int *p。 }。 main() { S s。 int *p=amp。 p[0]=4。 p[1]=3。 =p。 [1]=1。 [0]=2。 } 答案: [0]=2。行程序會(huì)崩潰 下列程序運(yùn)行到哪一行崩潰 ? 49 node *del(){ } 編程實(shí)現(xiàn)單鏈表刪除節(jié)點(diǎn) node *p1, *p2。 p1=head。 while(num!=p1dataamp。amp。p1next!=NULL){ p2=p1。p1=p1next。 } if(num==p1data) { if(p1=head) { head=p1next。 free(p1)。 } else p2next=p1next。 } else printf(\n%d could noe been found, num)。 return (head)。 50