版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、全国计算机等级考试二级教程-c 语言程序设计课后习题答案第一章1.1 exe 1.2 c obj exe 1.3 顺序选择 循环第二章一. 选择题2.1 b 2.2 d 2.3 b 2.4 a 2.5 c 2.6 a 2.7 b 2.8 b 2.9 d 2.10 c 2.11 b 2.12 b 2.13 a 二. 填空题2.14 11 12 2.15 4.2 4.2 2.16 定义执行语句2.17 关键字用户标识符2.18 int float double 2.19 float a1=1; float a2=1; 2.20 存储单元2.21 3.5 2.22 (a*b)/c a*b/c a/c
2、*b 2.23 把常量 10 赋给变量 s 2.24 位 1 或 0 2.25 8 127 0111111 -128 10000000 2.26 32767 -32768 1000000000000000 2.27 10 8 16 三. 上机改错题2.28 #include stdio.h; 删除行尾的 ; main(); / * main function * / 删除 ) 后的 ;, 注释中的 *要紧靠“ /”,即应为“ /* ”和“ */ ”函数开始处遗失了一个“ ”float r ,s ; /*/*r is radius*/,/* s is area of circuilar*/*/
3、注释符号不可嵌套使用r = 5.0 ; s = 3.14159 * r * r ; printf(%fn,s) 行尾遗失了“ ;”函数结束处遗失了一个“ ”2.29 #include stdio.h main /* main function */ main后遗失了“ ()” float a,b,c,v; /*a,b,c are sides, v is volume of cube */ a=2.0; b=3.0; c=4.0 行尾遗失了“ ;”精品学习资料 可选择p d f - - - - - - - - - - - - - - 第 1 页,共 37 页 - - - - - - - - -精
4、品学习资料 可选择p d f - - - - - - - - - - - - - - 第 1 页,共 37 页 - - - - - - - - -v=a*b*c; printf(%fn, v) 行尾遗失了“ ;” 第三章一. 选择题3.1 c 3.2 c 3.3 d 3.4 c 3.5 d 3.6 b 3.7 c 3.8 d 3.9 a 3.10 b 3.11 c 3.12 d 3.13 d 3.14 a 3.15 c 3.16 c 3.17 c 3.18 无答案3.19 c 3.20 b 二. 填空题3.21 (1)-2002500(2)i=-200,j=2500 (3)i=-200 j=2
5、500 3.22 12 0 0 3.23 一条语句; 3.24 ; 3.25 100,25.81,1.89234 100 25.81 1.89234 100 25.81 1.89234 3.26 x=127,x= 127,x= 177,x= 7f,x= 127 3.27 x=127,x=127 ,x=$127 ,x=$000127,x=%06d 3.28 a=513.789215,a= 513.79,a= 513.78921500,a= 513.78921500 三. 编程题和改错题3.29 修改后的程序如下:main() double a,b,c,s,v; printf(input a,b,
6、c:); scanf(%lf%lf%lf,&a,&b,&c); s =a*b; v=a*b*c; printf(a=%f,b=%f,c=%fn, a,b,c); printf(s=%f,v=%fn,s,v); 3.30 #include main() int a=560,b=60; printf(560 minute is %d hour and %d minute.n,a/b,a%b); 3.31 #include main() 精品学习资料 可选择p d f - - - - - - - - - - - - - - 第 2 页,共 37 页 - - - - - - -
7、 - -精品学习资料 可选择p d f - - - - - - - - - - - - - - 第 2 页,共 37 页 - - - - - - - - -int a,b; a=1500;b=350; printf(a div b is : %dn,a/b); printf(a mod b is : %dn,a%b); 3.32 #include main() double a,b,c,ave; printf (input 3 double number : n); scanf (%lf%lf%lf,&a,&b,&c); printf (%.1fn,(a+b+c)/3)
8、; 3.33 #include void main() int a,b,c,t; printf( 请依次输入整数a,b,c:); scanf(%d%d%d,&a,&b,&c); printf(n你输入的值是 : a=%d,b=%d,c=%dn,a,b,c); t=b;b=a;a=c;c=t; printf( 交换之后的值是 :a=%d,b=%d,c=%dn,a,b,c); 第四章一. 选择题4.1 a 4.2 a 4.3 a 4.4 d 4.5 c 4.6 a 4.7 b 4.8 c 4.9 d 4.10 c 二. 填空题4.11 非 0 0 4.12 = =同级 =
9、!= 同级4.13 ! & | 4.15 ! 4.16 a = b | a 4 | x -4 4.17 1 4.18 x 0 4.19 3 2 2 4.20 *# 三. 编程题4.21 略4.22 精品学习资料 可选择p d f - - - - - - - - - - - - - - 第 3 页,共 37 页 - - - - - - - - -精品学习资料 可选择p d f - - - - - - - - - - - - - - 第 3 页,共 37 页 - - - - - - - - -#include /* 检查日期的合法性*/ int checkdate(int year, in
10、t month, int day) if(year 2005) printf( 输入的年份无效 !n); return 0; else if(month 12) printf( 输入的月份无效 !n); return 0; else if(day 31) printf( 输入的日期无效 !n); return 0; else switch(month) case 4: case 6: case 9: case 11: if(day 30) printf( 输入的日期无效 !n); return 0; break; case 2: if(year%4 = 0 & year%100 !=
11、0) | year%400 = 0) if(day 29) printf( 输入的日期无效 !n); return 0; else 精品学习资料 可选择p d f - - - - - - - - - - - - - - 第 4 页,共 37 页 - - - - - - - - -精品学习资料 可选择p d f - - - - - - - - - - - - - - 第 4 页,共 37 页 - - - - - - - - - if(day 28) printf( 输入的出生日期无效!n); return 0; break; /* end of switch(m0)*/ return 1; vo
12、id main() int y0, m0, d0; /* 生日*/ int y1, m1, d1; /* 当前日期*/ int years, months, days; /* 实足年龄 */ printf( 请输入学生的生日:); scanf(%d%d%d, &y0,&m0,&d0); if(checkdate(y0, m0, d0) printf( 请输入当前日期 :); scanf(%d%d%d, &y1,&m1,&d1); /* 当前日期合法性检查*/ if(!checkdate(y1, m1, d1) return; else if(y0
13、 y1) printf( 出生年份比当前年份晚!n); return; else if(y0 = y1) if(m0 m1) printf( 出生年月比当前年月晚!n); return; else if(m0 = m1) 精品学习资料 可选择p d f - - - - - - - - - - - - - - 第 5 页,共 37 页 - - - - - - - - -精品学习资料 可选择p d f - - - - - - - - - - - - - - 第 5 页,共 37 页 - - - - - - - - - if(d0 d1) printf( 出生年月日比当前年月日晚!n); retur
14、n; /* 计算实足年龄*/ years = y1 - y0; months = m1 - m0; days = d1 - d0; /* 修正实足年龄天数*/ if(days 0) months-; switch(m1) case 1: case 5: case 7: case 10: case 12: days += 30; break; case 2: case 4: case 6: case 8: case 9: case 11: days += 31; break; case 3: if(y1%4 = 0 & y1%100 != 0) | y1%400 = 0) days +=
15、 29; else days += 28; 精品学习资料 可选择p d f - - - - - - - - - - - - - - 第 6 页,共 37 页 - - - - - - - - -精品学习资料 可选择p d f - - - - - - - - - - - - - - 第 6 页,共 37 页 - - - - - - - - - break; /* end of switch(m1) */ /* end of if(days 0) */ /* 修正实足年龄月数*/ if(months 0) months += 12; years-; /* end of if(months b)? a
16、:b; max=(tempc)? temp:c; printf (n); printf ( 你输入的数中最大的是%d.n,max); 4.25 (1) 不嵌套的 if 语句#include void main() int x,y; printf(input x :); scanf(%d,&x); if ( x-5 & x0 & x=10 | x=-5) printf(errorn); (2) 嵌套的 if 语句#include void main() int x,y; printf(input x :); scanf(%d,&x); printf(n); if(
17、x -5) printf(y is %d.n,y=x); else printf(error!n); if(0 = x) printf(y is %d.n,y=x-1); if(x 0) if(x -5 & x0 & x10 ) 精品学习资料 可选择p d f - - - - - - - - - - - - - - 第 9 页,共 37 页 - - - - - - - - -精品学习资料 可选择p d f - - - - - - - - - - - - - - 第 9 页,共 37 页 - - - - - - - - -printf(y is %d.n,y=x+1); else
18、 printf(error!n); (4)switch语句#include void main() int x,y; printf(input x : ); scanf(%d,&x); switch (x) case -4: case -3: case -2: case -1: printf(y is %d.n,y=x); break; case 0: printf(y is %d.n,y=x-1); break; case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: printf(y is %d
19、.n,y=x+1); break; default: printf(error!n); 第五章精品学习资料 可选择p d f - - - - - - - - - - - - - - 第 10 页,共 37 页 - - - - - - - - -精品学习资料 可选择p d f - - - - - - - - - - - - - - 第 10 页,共 37 页 - - - - - - - - -一. 选择题5.1 d 5.2 c 5.3 b 5.4 c 5.5 c 5.6 b 5.7 d 5.8 a 5.9 d 5.10 d 二. 填空题5.11 5 4 6 5.12 死循环5.13 -1 5.1
20、4 11 5.15 d=1.0 k+ k=0 x 三. 编程题5.17 #include void main() int i; int sig = 1; int sum = 0; for(i=1; i=101; i+,i+) sum += sig*i; sig *= -1; printf(sum=%dn, sum); 5.18 (1) #include void main() int i; double m=1.0; double e = 1.0; for(i=1; i= 0.0004) m *= i; e += 1/m; i+; printf(e=%fn,e); 5.19 #include
21、void main() int year; int col = 0; for(year=1600; year=2000; year+) if(year%4 = 0 & year%100 != 0) | year%400 = 0) printf(%dt, year); col+; if(col%5 = 0) printf(n); printf(n); 5.20 #include #define n 7 void main() 精品学习资料 可选择p d f - - - - - - - - - - - - - - 第 12 页,共 37 页 - - - - - - - - -精品学习资料
22、可选择p d f - - - - - - - - - - - - - - 第 12 页,共 37 页 - - - - - - - - - int i; int j; int m; int k = n/2; for(i=0; i m = i-k; if(m 0) m *= -1; for(j=0; j printf( ); for(j=0; j= 0 & striloop = 9) num = 10*num + (striloop - 0); iloop+; printf(%dn,num); 6.22 #include #include #define n 80 void main()
23、char strn; 精品学习资料 可选择p d f - - - - - - - - - - - - - - 第 14 页,共 37 页 - - - - - - - - -精品学习资料 可选择p d f - - - - - - - - - - - - - - 第 14 页,共 37 页 - - - - - - - - -int num = -1; do gets(str); num+; while(strcmp(str, eof); printf( 您输入了 %d 行字符! n,num); 6.23 #include #define n 80 void main() char strn; in
24、t iloop = 0; int num = 0; gets(str); while(striloop & iloop = a & striloop = z) num+; iloop+; printf( 您输入了字符中有%d 个小写字母! n,num); 6.24 #include void main() int line; int iloop1; int iloop2; printf( 请输入图案的行数(不大于 26):); scanf(%d, &line); for(iloop1 = 0; iloop1 line; iloop1+) for(iloop2 = 0;
25、iloop2 line - iloop1; iloop2+) 精品学习资料 可选择p d f - - - - - - - - - - - - - - 第 15 页,共 37 页 - - - - - - - - -精品学习资料 可选择p d f - - - - - - - - - - - - - - 第 15 页,共 37 页 - - - - - - - - - printf( ); for(iloop2 = 0; iloop2 2*iloop1+1; iloop2+) printf(%c,iloop1 + a); printf(n); 第七章一. 选择题7.1 c 7.2 c 7.3 b 7.
26、4 c 7.5 a 7.6 d 7.7 a 二. 填空题7.8 12 7.9 9.000000 7.10 4 7.11 n=1 s 7.12 =y z*x 7.13 1 s*i 0 f(k) 三. 程序调试和编程题7.14 fun(int n) int k,yes; for(k=2; k=n/2; k+) if(n%k = 0) yes = 0; break; else yes = 1; return yes; 7.15 int mymod(int a, int b) return a%b; 7.16 double fun(int n) 精品学习资料 可选择p d f - - - - - -
27、- - - - - - - - 第 16 页,共 37 页 - - - - - - - - -精品学习资料 可选择p d f - - - - - - - - - - - - - - 第 16 页,共 37 页 - - - - - - - - -double sum = 0; int iloop; int sig = -1; for(iloop=1; iloop=n; iloop+) sig *= -1; sum += sig*1.0/iloop; return sum; 7.17 double fun(int n) double t = 1.0; int iloop; long tmp; fo
28、r(iloop=2; iloop=n; iloop+) tmp = iloop*iloop; t -= 1.0/tmp; return t; 7.18 #include #include double fun(double x) return x*x + 5*x + 4; void main() int x = 2; printf(y1=%fn, fun(x); printf(y2=%fn, fun(x+15); printf(y3=%fn, fun(sin(x); 第八章一. 选择题8.1 a 8.2 b 8.3 b 8.4 c 8.5 b 8.6 b 8.7 c 8.8 d 8.9 b 8
29、.10 c 8.11 c 8.12 c 精品学习资料 可选择p d f - - - - - - - - - - - - - - 第 17 页,共 37 页 - - - - - - - - -精品学习资料 可选择p d f - - - - - - - - - - - - - - 第 17 页,共 37 页 - - - - - - - - -二. 填空题8.13 110 8.14 7 1 8.15 (1)char *p=&ch; (2) p=&ch; (3)scanf(%c,p); (4)*p=a; (5)printf(%c,*p); 8.16 (1)s=p+3; (2)s=s-2
30、 (3)50 (4)*(s+1) (5)2 (6)10 20 30 40 50 三. 编程题8.17 void fun(double x, double y, double *sum, double *div) *sum = x + y; *div = x - y; return; 8.18 void fun(double x, double y, double z, double *max, double *min) *max = x; *min = x; if(*max y) *max = y; if(*max y) *min = y; if(*min z) *min = z; retur
31、n; 第九章一. 选择题9.1 d 9.2 a 9.3 a 9.4 c 9.5 c 9.6 a 9.7 b 9.8 d 9.9 c 9.10 c 9.11 c 9.12 d 9.13 d 9.14 a 9.15 a 9.16 a 9.17 c 9.18 c 二. 填空题精品学习资料 可选择p d f - - - - - - - - - - - - - - 第 18 页,共 37 页 - - - - - - - - -精品学习资料 可选择p d f - - - - - - - - - - - - - - 第 18 页,共 37 页 - - - - - - - - -9.19 9 0 9.20 6
32、 9.21 12 9.22 3 9.23 2721 9.24 -850,2,0 9.25 k=p k 9.26 (c=getchar() c-a 三. 编程题9.27 #include #define n 81 int main() int counter10 = 0; int iloop = 0; char strn; gets(str); while(striloop) if(striloop = 0 & striloop = 9) counterstriloop - 0+; iloop+; for(iloop=0; iloop 10; iloop+) printf(%d - %d
33、n, iloop, counteriloop); return 0; 9.28 void fun(int array, int arraysize, int start) int iloop; if(start arraysize-1) if(start =0) start = 1; 精品学习资料 可选择p d f - - - - - - - - - - - - - - 第 19 页,共 37 页 - - - - - - - - -精品学习资料 可选择p d f - - - - - - - - - - - - - - 第 19 页,共 37 页 - - - - - - - - -for(ilo
34、op = start; iloop arraysize; iloop+) arrayiloop-1 = arrayiloop; for(iloop = 0; iloop arraysize; iloop+) printf(no.%d = %dn, iloop, arrayiloop); 9.29 int fun(int arry1, int arry2, int arrysize) int iloop; int counter = 0; for(iloop = 0; iloop arrysize; iloop+) if(arry1iloop % 2) arry2counter+ = arry1
35、iloop; return counter; 9.30 void fun(char array, int arraysize) int iloop1; int iloop2; char temp; /* 冒泡排序*/ for(iloop1 = 0; iloop1 arraysize - 1; iloop1+) for(iloop2 = 0; iloop2 arraysize - 1 - iloop1; iloop2+) if(arrayiloop2 arrayiloop2 + 1) temp = arrayiloop2; arrayiloop2 = arrayiloop2 + 1; array
36、iloop2 + 1 = temp; 精品学习资料 可选择p d f - - - - - - - - - - - - - - 第 20 页,共 37 页 - - - - - - - - -精品学习资料 可选择p d f - - - - - - - - - - - - - - 第 20 页,共 37 页 - - - - - - - - -9.31 #include void fun(int array, int arraysize, int inertnumber) int iloop; int iloop2; if(array0 arrayarraysize-1) for(iloop = 0;
37、 iloop inertnumber) for(iloop2 = arraysize - 1; iloop2 = iloop; iloop2-) arrayiloop2 + 1 = arrayiloop2; arrayiloop = inertnumber; break; if(iloop = arraysize) arrayarraysize = inertnumber; else for(iloop = 0; iloop arraysize; iloop+) if(arrayiloop = iloop; iloop2-) arrayiloop2 + 1 = arrayiloop2; arr
38、ayiloop = inertnumber; break; if(iloop = arraysize) arrayarraysize = inertnumber; 精品学习资料 可选择p d f - - - - - - - - - - - - - - 第 21 页,共 37 页 - - - - - - - - -精品学习资料 可选择p d f - - - - - - - - - - - - - - 第 21 页,共 37 页 - - - - - - - - - int main() int iloop; int a20 = 7,6,5,3,2,1; for(iloop = 0; iloop 6
39、; iloop+) printf(%d , ailoop); printf(n); fun(a, 6, 0); for(iloop = 0; iloop 7; iloop+) printf(%d , ailoop); printf(n); fun(a, 7, 4); for(iloop = 0; iloop 8; iloop+) printf(%d , ailoop); printf(n); fun(a, 8, 8); for(iloop = 0; iloop 9; iloop+) printf(%d , ailoop); printf(n); return 0; 9.32 int fun(i
40、nt number, int array) int iloop = 0; int iloop2; int binlen; int midnumber; int div; int remain; midnumber = number; do 精品学习资料 可选择p d f - - - - - - - - - - - - - - 第 22 页,共 37 页 - - - - - - - - -精品学习资料 可选择p d f - - - - - - - - - - - - - - 第 22 页,共 37 页 - - - - - - - - - div = midnumber/2; remain = m
41、idnumber%2; midnumber = div; arrayiloop+ = remain; while(midnumber); binlen = iloop; for(iloop2 = 0, iloop = binlen - 1; iloop2 iloop; iloop2+, iloop-) midnumber = arrayiloop2; arrayiloop2 = arrayiloop; arrayiloop = midnumber; return binlen; 9.33 #include #include #define n 15 void fun(int array, in
42、t arraysize) int x; int iloop; int iloop2; for(iloop = 0; iloop 0) x = rand()%20; iloop2 = 0; iloop2+; while(iloop2 iloop); arrayiloop = x; 精品学习资料 可选择p d f - - - - - - - - - - - - - - 第 23 页,共 37 页 - - - - - - - - -精品学习资料 可选择p d f - - - - - - - - - - - - - - 第 23 页,共 37 页 - - - - - - - - -int main()
43、 int an; int iloop; fun(a, n); for(iloop = 0; iloop n; iloop+) printf(%dn, ailoop); return 0; 第十章一. 选择题10.1 c 10.2 b 10.3 c 10.4 b 10.5 c 10.6 a 10.7 c 10.8 a 10.9 c 10.10 c 二. 填空题10.11 gfedcb 10.12 xyz 10.13 so 10.14 10 10.15 itis 10.16 strlen(str)-1 j- 10.17 3 10.18 goodgood !三. 编程题10.19 char* myg
44、ets(char *str) int iloop = 0; char ch; while(ch=getchar() != n) striloop+ = ch; striloop = 0; return str; char * myputs(char *str) 精品学习资料 可选择p d f - - - - - - - - - - - - - - 第 24 页,共 37 页 - - - - - - - - -精品学习资料 可选择p d f - - - - - - - - - - - - - - 第 24 页,共 37 页 - - - - - - - - - int iloop = 0; whi
45、le(striloop) putchar(striloop+); putchar(n); return str; 10.20 #include #include int fun(char *str) int len; int iloop1; int iloop2; int result = 1; len = strlen(str); for(iloop1 = 0, iloop2 = len - 1; iloop1 len) return null; ch = strpos; for(iloop = pos; iloop len - 1; iloop+) striloop = striloop
46、+ 1; strlen-1 = 0; return ch; 第十一章一. 选择题11.1 d 11.2 b 11.3 a 11.4 c 二. 填空题11.5 ijklefghabcd 11.6 7 11.7 8 11.8 *(s+j) i+1 i 11.9 17 11.10 (*fun)() (*fun)(a+i*h)/h mypoly 三. 编程题11.11 #include #include #define n 81 int main(int argc, char *argv) char sig; int dig; int pos; char strn = 0; char outstrn
47、= 0; 精品学习资料 可选择p d f - - - - - - - - - - - - - - 第 26 页,共 37 页 - - - - - - - - -精品学习资料 可选择p d f - - - - - - - - - - - - - - 第 26 页,共 37 页 - - - - - - - - -if(argc 2) sig = -; dig = 10; else sig = argv10; dig = argv11 - 0; printf( 请输入一个字符串:); gets(str); if(sig = -) pos = strlen(str) - dig; if(pos dig
48、) pos = dig; outstrpos = 0; printf( 处理后的字串为:); printf(%sn, outstr); return 0; 11.12 #include #include 精品学习资料 可选择p d f - - - - - - - - - - - - - - 第 27 页,共 37 页 - - - - - - - - -精品学习资料 可选择p d f - - - - - - - - - - - - - - 第 27 页,共 37 页 - - - - - - - - -void movebin(char *bin) int len; int iloop; len
49、= strlen(bin); for(iloop = len; iloop 0; iloop-) biniloop = biniloop - 1; return; void fun(int n, char *bin) int pos; pos = strlen(bin); if(n = 0) return; if(n = 1) movebin(bin); bin0 = 1; return; movebin(bin); bin0 = (n%2) + 0; n /= 2; fun(n, bin); return; int main() int a = 4; char bin50 = ; fun(a
50、, bin); printf(%sn, bin); return 0; 11.13 精品学习资料 可选择p d f - - - - - - - - - - - - - - 第 28 页,共 37 页 - - - - - - - - -精品学习资料 可选择p d f - - - - - - - - - - - - - - 第 28 页,共 37 页 - - - - - - - - -#include long fun(int n) if(n = 1) return n; else return fun(n-1) + n; int main() int num; int sum; printf(
51、请输入一个自然数:); scanf(%d, &num); sum = fun(num); printf( 结果是: %dn, sum); return 0; 11.14 #include int fun(int n) if(n = 0 | n = 1) return 1; else return fun(n-1) + fun(n-2); int main() 精品学习资料 可选择p d f - - - - - - - - - - - - - - 第 29 页,共 37 页 - - - - - - - - -精品学习资料 可选择p d f - - - - - - - - - - - -
52、- - 第 29 页,共 37 页 - - - - - - - - -int num; int result; printf( 请输入一个自然数:); scanf(%d, &num); result = fun(num); printf( 斐波拉契级数为:%dn, result); return 0; 第十二章一. 选择题12.1 b 12.2 b 12.3 a 12.4 c 12.5 d 12.6 b 12.7 a 12.8 a 二. 填空题12.9 2,5,1,2,3,-2 12.10 2468 第十三章一. 选择题13.1 a 13.2 c 13.3 b 13.4 c 13.5
53、d 13.6 d 13.7 d 二. 填空题13.8 ar=9 ar=9 ar=11 13.9 int* s *b 三. 编程题13.10 #define myalpha(c) (c=a & c=a & c=z) ? 1 : 0 13.11 #define swap(t,x,y) t tmp; tmp=x; x=y; y=tmp; 13.12 #include #include int main() int *p; int tmp; int iloop; int iloop2; 精品学习资料 可选择p d f - - - - - - - - - - - - - - 第 30 页
54、,共 37 页 - - - - - - - - -精品学习资料 可选择p d f - - - - - - - - - - - - - - 第 30 页,共 37 页 - - - - - - - - -p = (int *)malloc(sizeof(int)*3); scanf(%d%d%d, p,p+1,p+2); for(iloop = 0; iloop 2; iloop+) for(iloop2 = 0; iloop2 *(p + iloop2 + 1) tmp = *(p + iloop2); *(p + iloop2) = *(p + iloop2 + 1); *(p + iloop
55、2 + 1) = tmp; printf(%d %d %dn, *p, *(p+1), *(p+2); free(p); p = null; return 0; 第十四章一. 选择题14.1 d 14.2 d 14.3 d 14.4 a 14.5 c 14.6 c 14.7 c 14.8 b 二. 填空题14.9 struct link *next 14.10 p-next mp-data 14.11 (struct list*) struct list struct list* struct list return h 三. 编程题14.12 #include #define n 3 str
56、uct stud char num5, name10; int s4; double ave; ; void readrec(struct stud array, int size) 精品学习资料 可选择p d f - - - - - - - - - - - - - - 第 31 页,共 37 页 - - - - - - - - -精品学习资料 可选择p d f - - - - - - - - - - - - - - 第 31 页,共 37 页 - - - - - - - - - int iloop; for(iloop=0; iloop scanf(%s%s%d%d%d%d, arrayil
57、oop.num, arrayil, &arrayiloop.s0, &arrayiloop.s1, &arrayiloop.s2, &arrayiloop.s3); arrayiloop.ave = (arrayiloop.s0 + arrayiloop.s1 + arrayiloop.s2 + arrayiloop.s3)/4.0; return; void writerec(struct stud array, int size) int iloop; for(iloop=0; iloop printf(%st%st%dt%dt%dt%dt%
58、fn, arrayiloop.num,arrayil,arrayiloop.s0, arrayiloop.s1,arrayiloop.s2,arrayiloop.s3, arrayiloop.ave); return; int main() struct stud stun; readrec(stu, n); writerec(stu, n); return 0; 14.13 #include #include #define n 100 struct node int data; struct node* next; 精品学习资料 可选择p d f - - - - - - -
59、 - - - - - - - 第 32 页,共 37 页 - - - - - - - - -精品学习资料 可选择p d f - - - - - - - - - - - - - - 第 32 页,共 37 页 - - - - - - - - -; int seekmaxvalue(struct node *pnode) int max; struct node* pmove; pmove = pnode; max = pmove-data; pmove = pmove-next; while(pmove) if(max data) max = pmove-data; pmove = pmove-
60、next; return max; struct node* seekmaxvalueaddress(struct node *pnode) int max; struct node* maxaddress; struct node* pmove; pmove = pnode; max = pmove-data; maxaddress = pmove; pmove = pmove-next; while(pmove) if(max data) max = pmove-data; maxaddress = pmove; pmove = pmove-next; return maxaddress; int main() 精品学习资料 可选择p d f - - - - - - - - - - - - - - 第 33 页,共 37 页 - - - - - - - - -精品学习资料 可选择p d f - - - - - - - - - - - - - - 第 33 页,共 37 页 - - - - -
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026南亚户外家具制造行业供需分析及趋势发展评估报告
- 2026年兽医临床技能考试模拟试题(附答案)
- 基于第一性原理探究热电化合物输运及相关性质
- 基于立体测量的运动数据采集方法:设计、实现与应用探索
- 基于移动社交网络属性的D2D卸载策略:理论、实践与创新
- 基于离散变量的大跨度网架结构:力学特性剖析与优化设计策略
- 基于神经网络的数据融合选线方法:原理、应用与仿真分析
- 基于眼模型的眼底荧光相机:技术突破与临床应用新进展
- 基于相似工程判别的公路隧道工程造价指数预测:理论、模型与实践
- 经期不规律问题的诊断与调理
- 超市员工晋升管理办法
- 儿童电除颤教学课件
- 劳动监察培训课件
- 中铁机关管理制度
- 东北林业大学《生物科学专业英语》2023-2024学年第二学期期末试卷
- 建筑物拆除工程合同模板
- DB32T 3262-2017 移动泵机组运行与维护规范
- 会计基础第四版 课件 项目四 运用借贷记账法
- 2024年全国职业院校技能大赛高职组(社区服务实务赛项)考试题库(含答案)
- 计算机网络的发展
- 地面打磨施工方案
评论
0/150
提交评论