c语言第九章作业答案第三版,C语言程序设计教学课件作者第3版乌云高娃补充习题及答案C语言程序设计教学课件作者第3版乌云高娃补充习题及答案第9章补充习题及答案课件.doc...

C语言程序设计教学课件作者第3版乌云高娃补充习题及答案C语言程序设计教学课件作者第3版乌云高娃补充习题及答案第9章补充习题及答案课件.doc

第9章补充习题及答案

习题

9.1 选择题

(1)设int i,*p= &i;以下语句正确的是 。

A.*p=10; B.i=p; C.i=*p; D.p = 2*p+1;

(2)设char chStr[10],*pStr=chStr; 以下语句不正确的是 。

A.pStr= chStr +5;B.chStr=pStr+ chStr;

C.chStr [2]=pStr [4]; D.*pStr = chStr [0];

(3)以下程序的执行结果是 。

#include "stdio.h"

void main()

{int iA[ ]={1,2,3,4,5,6};

int *pInt;

pInt = iA;

*(pInt+3)+=2;

printf("%d,%d\n",*pInt,*(pInt+3));

}

A.1,3 B.1,6 C.3,6D.1,4

(4)以下fnMycomp(?)函数的功能是按词典顺序比较两个字符串chStr1和chStr2的大小。如果chStr1大于chStr2,则返回正值;等于则返回0;小于则返回负值。请选择正确的编号 填空。

int fnMycomp(char *chStr1,char *chStr2)

{

for( ; chStr1==chStr2; )

if(*chStr1== '\0')return (0);

return (*chStr1-*chStr2);

}

A.chStr1++B.chStr2++

C.chStr1++;chStr2++D.chStr1++,chStr2++

(5)以下fnMycopy()函数的功能是将两个字符串chStr1和chStr2连接起来。请选择正确的编号填空。

void fnMycopy(char *chStr1, char *chStr2)

{

char *pStr=chStr1;

while(*chStr1) ① ;

while(*chStr2)

{

*chStr1= ② ;

chStr1++;

chStr2++;

}

*chStr1 = '\0';

③ ;

}

① A.chStr1-- B.chStr1++ C.chStr1D.*chStr1

② A.*chStr2 B.chStr2 C.chStr2-- D.*chStr2++

③ A.return (chStr1)B.return (chStr2)

C.return(pStr) D.return(pStr-chStr2)

9.2 填空题

(1)以下程序的执行结果是 。

#include "stdio.h"

void main()

{int iA = 10;

int*pInt=&iA;

printf("*p=%d, iA=%d\n", *pInt,iA);

*pInt = 100;

printf("*p=%d, iA=%d\n", *pInt, iA);

}

(2)以下程序的执行结果是 。

#include "stdio.h"

void main()

{int*pInt;

intiNum;

pInt = &iNum;

*pInt = 2;

pInt++;

printf("%d,", *pInt);

pInt--;

printf("%d\n", *pInt);

}

(3)以下程序是将"Hello"逆向显示出来。请将程序补充完整。

#include "stdio.h"

void fnPt(char *p);

void main()

{

fnPt("Hello");

}

void fnPt(char *pString)

{ int i= ① ;

char *pStr =pString;

while(pStr[i])i++;

i--;

while(i>=0)

{printf("%c",pStr[i]);

② ;

}

}

(4)下列程序的输出结果是 。

#include "stdio.h"

void main()

{int iData[ ]={1,2,3,-4,5};

int iM,iN,*pInt;

pInt=&iData[0];

iM=*(pInt+2);

iN=*(pInt+4);

printf("*pInt=%d,m=%d,n=%d\

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值