j=0;
while (j p=lineptr[j++]; while ((k=index(p,word[i]))>=0) del_word(p,k,strlen(word[i])); } } writelines(lineptr,nlines); } } 14. #include main() { float peven(),podd(),dcall(); float sum; int n; while (1) { scanf(\ if(n>1) break; } if(n%2==0) { printf(\ sum=dcall(peven,n); } else { printf(\ sum=dcall(podd,n); } printf(\} float peven(int n) { float s; int i; s=1; for(i=2;i<=n;i+=2) s+=1/(float)i; return(s); } float podd(n) int n; { float s; int i; s=0; 26 for(i=1;i<=n;i+=2) s+=1/(float)i; return(s); } float dcall(fp,n) float (*fp)(); int n; { float s; s=(*fp)(n); return(s); } 15. #include #include { char str1[20],str2[20],*p1,*p2; int sum=0; printf(\scanf(\p1=str1;p2=str2; while(*p1!='\\0') { if(*p1==*p2) {while(*p1==*p2&&*p2!='\\0') {p1++; p2++;} } else p1++; if(*p2=='\\0') sum++; p2=str2; } printf(\getch();} 16. 程序提示:报数程序段如下: for(i=0;i i=0;//i为现正报数的人的编号 k=0;//k为1.2.3计数时的计数变量 m=0;//m为退出的人数 while(m if(*(p+i)!=0)k++; if(k==3)//对退出的人的编号置0 { *(p+i)=0; k=0; m++; } 27 i++; if(i==n)i=0; } 17. #include void sort(int **p,int n) { int i,j,*temp; for(i=0;i void main() { void sort(int **p,int n); int i,n,data[10],**p,*pstr[10]; printf(\ scanf(\ for(i=0;i pstr[i]=&data[i]; printf(\ for(i=0;i scanf(\ p=pstr; sort(p,n); printf(\ for(i=0;i printf(\ printf(\} 18. #include void main() { char *p[7]={\ char **pp=p; //二级指针指向指针数组的首地址 int data; printf(\输入0~6的整型数:\ scanf(\ printf(\ //二级指针间接引用字符串 } 第7章 结构体与共用体 一、选择题 1 B D 2 C C 3 D D 4 D D 5 D D 6 C A 7 B B 8 D C 9 B C 10 11 12 13 14 15 16 17 18 19 20 C D A C 28 C D C C A C C D D B A A D A B A 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 B B 41 42 43 44 45 46 47 48 B C C A D C A C 二、填空题 1. ① 12② 0 2. ①struct DATA d={2010,10,1}; 3. ①struct DATE d = {2006,10,1}; 4. ①成员(.)②-> 5. ①内存大小②声明新的类型名 6. ①enum 7. ①100 8. ①p->no=1234 9. ①;p!=NULL;p=p->next; ②m=p->data; 10. ①struct stu_type st[N] ②i 12. ①student.no②student.birthday.year, 13. ①STDTS *p=&s1 ②p->score 15. ①strcmp(q[i].name,a)==0②q[j+1]=q[j]; 16. ①weekday②(n>=0)&&(n<=6) 17. ①w[i].b 18. ①m=a[i].n ②b[j++]=a[i]③i 21. ①sizeof(struct A))②sizeof(union B)) 22. ①a1=inputstru();②return x; 23. ①STU *x,int n②p 24. ①strcmp(a.name,b.name)>0②strcmp c.name,d.name)>0 25. ①STU stu[N],*p;②i=0,p=stu 26. ①p=(struct node *)malloc(sizeof(struct node));②free(q) 三、程序分析题 1. 10,2 2. zhao,m,85,90 3. 2,4 4. 张飞, 50, 66.600000 5. 张飞, 30, 66.600000 6. 张飞, 50, 66.600000 7. 关羽, 25, 88.800000 8. 4 8 9. 24 10. 80 11. 2,4,3,9,12,12,11,11,18,9, 12. CC,33 13. 1001,ChangRong,1098.0 14. 5 15. 13413 16. 5 29 17. 5/8 is the 128th day in 1998. 18. 20,15 19. 200,y 20. Number=10102 Name= Fu ping Sex=F Score=92.5 21. 1,2 22. 1234 12 34 12ff 23. 10,x 24. 5,3 25. 3,a 26. 07101 li jia 89.50 07103 li jian 90.6 07105 li dan 85.8 27. sum=425.00 average=85.00 count90=2 28. No Name Sex Score 10101 Zou pin M 75 10102 Yu bin M 82.5 20103 Li fang F 92.5 20104 Che lin F 87 30105 Wang mi M 88 29. All students are: liu f 78 li m 88 wang f 83 The student is: li m 88 30. number=10102 name=Zhang zhe sex=M score=88.500000 number=10102 name=Zhang zhe sex=M score=88.500000 number=10102 name=Zhang zhe sex=M score=88.500000 31. st= 101 Zhang M 19 89.00 score= 89.00 score= 95.00 32. st= 101 Zhang M 19 89.00 st= 101 Zhang M 19 89.00 t= 101 Zhang M 19 89.00 t= 101 Zhang M 19 95.00 st= 101 Zhang M 19 89.00 30 百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库程序设计上机实验课后答案(6)在线全文阅读。
相关推荐: