资源描述:
《C语言考精彩试题及问题详解(8)》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、实用标准一、单项选择题:(10分,每题2分)1.char*p[10];该语句声明了一个:。A)指向含有10个元素的一维字符型数组的指针变量pB)指向长度不超过10的字符串的指针变量pC)有10个元素的指针数组p,每个元素可以指向一个字符串D)有10个元素的指针数组p,每个元素存放一个字符串2.若intx;且有下面的程序片断,则输出结果为:。for(x=3;x<6;x++){printf((x%2)?"##%d":"**%d",x);}A)##3B)**3C)**3D)##3**4**4##4##4**5##5##5**53.在while(!x)语句中的!x
2、与下面条件表达式等价的是:。A)x!=0B)x==1C)x!=1D)x==04.已知structpoint{intx;inty;};structrect{structpointpt1;structpointpt2;};structrectrt;structrect*rp=&rt;则下面哪一种引用是不正确的________。A)rt.pt1.xB)(*rp).pt1.xC)rp->pt1.xD)rt->pt1.x5.若二维数组a有m行n列,则下面能够正确引用元素a[i][j]的为:。A)*(a+j*n+i)B)*(a+i*n+j)C)*(*(a+i)+j)D)*
3、(*a+i)+jCDDDC二、分析程序并写出运行结果。(25分,每题5分)1.#includemain(){intn;staticchar*monthName[]={"Illegalmonth","January","February","March","April","May","June","July","August","September","October","November","December"};for(n=1;n<=12;n++){printf("%s",monthName[n]);}}运行结果是:JanuaryFeb
4、ruary文档大全实用标准MarchAprilMayJuneJulyAugustSeptemberOctoberNovemberDecember2.#include#defineARR_SIZE7voidYH(inta[][ARR_SIZE],intn);voidPrintYH(inta[][ARR_SIZE],intn);main(){inta[ARR_SIZE][ARR_SIZE];YH(a,ARR_SIZE-1);PrintYH(a,ARR_SIZE-1);}voidYH(inta[][ARR_SIZE],intn){inti,j;fo
5、r(i=1;i<=n;i++){for(j=1;j<=i;j++){if(j==1
6、
7、i==j){a[i][j]=1;}else{a[i][j]=a[i-1][j-1]+a[i-1][j];}}}}voidPrintYH(inta[][ARR_SIZE],intn){inti,j;for(i=1;i<=n;i++){for(j=1;j<=i;j++){printf("%4d",a[i][j]);}printf("");}}运行结果是:1111211331文档大全实用标准14641151010513.#includemain(){inti,
8、n;for(i=1;i<=5;i++){printf("Pleaseentern:");scanf("%d",&n);if(n<=0)continue;printf("n=%d",n);}printf("Programisover!");}程序运行时输入:1-23-45↙运行结果是:n=1Pleaseentern:Pleaseentern:n=3Pleaseentern:Pleaseentern:n=5Programisover!4.#includevoidFunc(intn);main(){inti;for(i=0;i<2;i++)
9、{Func(i);}}voidFunc(intn){staticintt=1;printf("t=%d",t++);}运行结果是:t=1t=25.#includeintFunc(inti);main(){inti;for(i=3;i<5;i++){printf("%d",Func(i));}文档大全实用标准printf("");}intFunc(inti){staticintk=10;for(;i>0;i--){k++;}return(k);}运行结果是:1317三、阅读并完成程序,在标有下划线的空白处填入适当的表达式或语句,使程序完
10、整并符合题目要求。(20分,每空2分)