复习题_高级语言程序设计基础.pdf
高级语言程序设计基础复习题1、c 语言程序的基本单位是什么?它的结构又如何?c 语言程序的总体结构是怎样的?主函数 main()在程序中的地位如何?【答案】函数是 c 语言程序的基本模块单元。任何函数(包括主函数main()都是由函数说明和函数体两部分组成。其一般结构如下:函数类型 函数名(函数参数表)说明语句部分;执行语句部分;一个完整的c 语言程序,是由一个、且只能由一个main()函数(又称主函数)和若干个其他函数结合而成的,或仅由一个main()函数构成。main()函数的作用相当于其他高级语言中的主程序;其他函数的作用相当于子程序。一个 c 语言程序,总是从main()函数开始执行,而不论其在程序中的位置。当主函数执行完毕时,亦即程序执行完毕。习惯上,将主函数main()放在最前头。2、算法分析的目的是什么?【答案】算法分析是指对一个算法的运行时间和占用空间做定量的分析,一般计算出相应的数幂级,常用时间复杂度和空间复杂度表示。分析算法的目的就是要降低算法的时间复杂度和空间复杂度,提高算法的执行效率。3、分析下面程序的执行过程,并给出输出结果。main()int x=3,y=6,a=0;while(x+!=(y-=1)a+=1;if(yx)break;primf(x=d,y=d,a=dn,x,y,a);【答案】对于 x+中 x 值的引用时,应当是先引用后自加,第一次 while 循环:条件为真,执行 a=a+l=l;此时,x 的值已为4,判断 yx 不成立,继续执行循环;第二次while 循环:条件为假,此时 x 的值已为 5,退出 while 循环,执行printf 输出结果为x=5,y=4,a=l。4、面程序并给出正确结果。main()int x=3;do printf(d,x-);while(!x);【答案】本题 x 赋初值为3,当执行 printf(%d,x-);时,由于X-的作用是先运算x,再将 x 的值减l,所以,printf 输出的 x 值为 3,等输出后,x 的值减 1 变为 2,继续执行,判断条件!x 为假,循环只被执行一次。5、分析下面程序的执行过程,给出输出结果。#include main()int i=0,a=0;while(iy?x:y;int f2(int x,int y)return xy?y:x;main()int a=4,b=3,c=5,d,e,f;d=f1(a,b);d=fl(d,c);e=f2(a,b);e=f2(e,C);f=a+b+c-d-e;printf(d,d,dn,d,e,f);【答案】函数 f1 是一个求两个整数中最大值的函数,函数f2 是一个求两个整数中最小值的函数。在main 函数中两次调用函数f1,求得变量a、b、c 中的最大值赋值给d;两次调用函数f2,求得变量a、b、c 中的最小值赋值给e;表达式a+b+c-d-e 得到中间值,输出5,3,4。9、分析下面程序的执行过程,给出输出结果。f(int b,int m,int n)int i,s=0;for(i=m;in;i=i+2)s=s+bi;return s;)main()int x,a=1,2,3,4,5,6,7,8,9;x=f(a,3,7);printf(dn,x);)【答案】本题中,主函数调用f 函数,在 f 函数中执行了两次循环,第一次i=3,s=0+bi:4,然后 i的值被修改成5,仍然满足循环条件,进入第二轮循环,s=4+b5=4+6=10,随后,i 的值被修改成 7,不再满足循环条件,退出循环,返回s 的值。所以最后输出结果是10。10、以下函数的功能是计算s=1+12!+1 3!+l n!,根据题意,完善程序。double fun(int n)double s=0.0,fac=1.0;int i;for(i=1;i=n;i+)fac=fac【1】;s=s+【2】;return【3】;文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2【答案】【1】i 或*1 0i 或*1I 或*(1 0 i)或(double)i;【2】fac;【3】s/*分析:该程序实现的功能是求各个因式的和,观察表达式可以看出,只要将i 的值的倒数乘以 fac 就得到每个因式的值。*/11、wap 函数的功能是交换a 和 b 的值,该函数调用后能否实现交换【3】。根据题意,完善程序。void swap(int x,int y)int t;【1】;x=y;y=t;main()int a=3,b=4;【2】;printf(%d%d,a,b);【答案】【1】t=x;【2】swap(a,b);【3】不能/*评析:用变量作为函数的实参时,属单向传递,即值传送 方式,此种函数参数的传递方式只能由实参传给形参,不能由形参传回来给实参。*/12、根据下面程序说明strcpy(strl,s1)、strcat(str2,s1)的作用,给出程序的输出结果。#include main()char pl7=abc,p2=ABC,str50=xyz;strcpy(str,strcat(pl,p2);printf(s,str);【答案】strcpy(strl,s1)的作用是将字符串s1 拷贝到 strl 中去,并将结果放在strl1 中,函数调用后返回 strl 的地址。strcat(str2,s2)的作用是将s2接到字符串str2 的后面,并将结果放在str2中,函数调用后返回str2 的地址。本题定义了三个字符数组pl,p2,str,strcat(p1,p2)函数的作用是将字符串数组p2 接到字符串p1 的后面,结果放在字符数组p1,再通过 sffcpy()函数将该字符串拷贝到str 数组中,原str数组中的字符串xyz 被覆盖,因此打印输出字符串str 即可得到abcABC。13、以下面程序为例说明strlen(st)和 sizeof(st)的输出结果。main()char st20=hello0t;printf(ddn,strlen(st),sizeof(st);文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2【答案】c 语言中字符串是以 0字符结束的,且 strlen()函数计算的是 0字符前的所有字符的个数。本题中 strlen(st)应为 5。数组定义以后系统就为其分配相应大小的内存空间,而不论其中有没有内容。Sizeof()函数是计算变量或数组的所分配到的内存空间的大小。所以本题的sizeof(st)为 20。14、下面程序的功能是将矩阵a 中和值最大的那一行元素与首行元素对换。根据题意,完善程序。main()int a1010,i,j,t,s,smax,imax;for(i=0;i10;i+)for(j=0;j10;j+)【1】;smax=-32768;for(i=0;i10;i+)s=0;for(j=0;jsmax)smax=s;imax=i;for(j=0;j10;j+)t=a0j;a0j=aimaxj;【3】;for(i=0;i10;i+)printf(“n”);for(j=0;j10;j+)printf(“%d”,aij);【答案】【1】scanf(“%d”,&aij);;【2】s+=aij;【3】aimaxj=t;/*分析:首先要输出数组元素的值,分别求每行的元素和,注意s=0 保持每行计算初始值清0,然后要对值最大的那一行元素与首行元素对换*/15、下面程序的功能是将两个有序的数组合并到另一个数组中,合并后仍有序。根据题意,完善程序。main()int i=0,m=5,a6=1,2,3,7,9,15;int j=0,n=6,b7=3,5,8,12,15,16,18,;int k=0,c13;while(i+jm+n)if(【1】)ck+=ai+;else if(【2】)ck+=bj+;else if(【3】)ck+=ai+;else ck+=bj+;文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2for(i=0;i=n;【2】i=m;【3】aibj;16、分析下面程序段的结果是什么?main()int a=5,*b,*c;c=&b;b=&a;printf(d,*c);【答案】指针变量是用来存放地址的。*:指针运算符;&:取地址运算符;*c表示为指针变量*c所指向的存储单元,*c 表示为指针指针变量c 所指向的存储单元,本题中 c=&b 表示 c 为变量 b 的地址,b=&a 表示 b 为变量 a 的地址。表达式*c 的值就是变量a 中的值(5)。17、若有说明:int n=2,*p=&n,*q=p;,则语句q=p*n;是否合法?【答案】指针变量不同于整型变量和其它类型的变量,它是用来存放地址(指针)的,不能将一个整型量(或任何其它非地址类型的数据)赋给一个指针变量,这样的赋值是不合法的。18、fun 函数的功能是求3 行 4 列二维数组每行元素中的最大值。根据题意,完善程序。void fun(int m,int n,int ar4,int*br)int i,j,x;for(i=0;im;i+)x=ari0;for(j=0;jn;j+)if(x【1】)x=arij;_【2】_=x;【答案】【1】arij;【12】brI 或*(br+i)19、以下程序中函数huiwen的功能是检查一个字符串是否是回文(回文即正向与反向的拼写都一样),当字符串是回文时,函数返回字符串:yes!,否则函数返回字符串:no!,并在主函数中输出。根据题意,完善程序。#include char*huiwen(char*str)char*pl,*p2;int i,t=0;pl=str;p2=_【1】_;for(i=0;i=strlen(str)/2;i+)if(*pl+!=*p2-)t=l;文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2break;if(_【2】_)retum(yes!);else return(no!);main()char str50;printf(Input:);scanf(%s,str);printf(%sn,_【30】_);【答案】【1】pl+(strlen(str)-1)或 str+(strlen(str)-1);【2】t=0 或!(tl=0)或 t!=l 或!t;【3】huiwen(str)20、分析下面程序段的执行过程,解释sizeof 函数的功能,并给出执行结果。(用 small 模式编译,指针变量占2 个字节)。struct date long*cat;struct date*next;double dog;too;printf(d,sizeof(too);【答案】sizeof 函数计算已知类型所占的字节数。结构体变量所占内存长度是各成员占的内存长度之和。指针变量占2个字节,所以cat 和*next 各占 2 个字节;double 型占 8 个字节,故too 共占 12 个字节。21、如何定义一个指向结构体变量的指针?【答案】一个结构体变量指针就是该变量所占据的内存段的起始地址。可以设一个指针变量,用来指向一个结构体变量,此时该指针变量的值是结构体变量的起始地址。指针变量也可以用来指向结构体数组中的元素。例如:struct node int info;struct node*link;22、1、c 语言文件的打开和关闭函数的调用方式。【答案】C 语言中的文件分为:ASCII 文件与二进制文件。文件在使用前打开,使用后要关闭。打开文件的函数为:fopen(),调用形式为:fp=fopen(文件名,使用文件方式);关闭文件的函数为:fclose(),调用形式为:fclose(fp);其中 fp 为文件指针。23、执行下述程序的输出结果为()。文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2文档编码:CO8U10T2M8N4 HY7L2E7T1U9 ZS1O4A7W5X2#include main()int n=0;int sum=0;while(n+,n50)if(n=(n/2)*2)continue;sum+=n;printf(%dn,sum);【答案】625 24、下面程序将二维数组a 的行和列元素互换后存到另一个二维数组b 中。补全程序。main()int a23=1,2,3,4,5,6;int b32,I,j;printf(“array a:n”);for(i=0;i=1;i+)for(j=0;(1);j+)printf(“%5d”,aij);(2)printf(“n”);printf(“array b:n”);for(i=0;(3);i+)for(j=0;j=1;j+)printf(“%5d”,bij);printf(“n”);【答案】1)j=2;2)bji=aij 3)iy 则将 x与 y 的值进行交换,然后再用 x 与 z