/***************found**************/
scanf(\ } for (i=0;i<3;i++)
/***************found**************/ ___3___
printf(\ main(){ fun();}
第一空:sum=0 第二空:& 第三空:sum=sum+a[i][i]; 78.给定程序的功能是求下列分数序列的前n项之和。n值从键盘输入,和值通过函数值返回主程序输入。
21,32,53,813215,8,18,??例如:若n=5,则应该输出:8.391667 #include for(i=0;i for(j=i+1;j if (strcmp(sp[k].name,sp[j].name)>0) k=j; temp=sp[k];sp[k]=sp[i];sp[i]=temp; }} outdata(USER *sp) { int i; printf(\ for (i=0;i printf(\main(){ USER sp[N],temp; getdata(sp); getsort(sp); outdata(sp);} 第一空:USER *sp 第二空:gets 第三空:gets 80. 给定程序的功能是读入五位用户的姓名和电话号码,按姓名的字典顺序排列后,输出用户的姓名和电话号码。函数getdata读入五位用户的姓名和电话号码。getsort函数把数据按姓名的字典顺序排序。outdata输出最后的结果。 #include 第一空:USER temp 第二空:sp[k]=sp[i]; 第三空:sp[i]=temp; 81.给定程序的功能是找出方阵中每列最小元素以及所在的行号。函数findmin找出每列中最小元素所在行号,函数outdata输出方阵中每列最小元素及其所在行号。 #include { int s[M][M]={{14,23,52,3}, {34,22,52,41},{12,15,8,9},{54,98,23,21}}; int im[M]; findmin(s,im); outdata(s,im);} findmin(int a[][M],int ln[]) { int i,j,t; for (i=0;i /***************found***************/ for(j=1;___1___;j++) if(a[j][i] /***************found***************/ ___2___; }} outdata(int(*a)[M],int *ln) { int i,j; printf(\ for(i=0;i printf(\ printf(\ } printf(\ for (i=0;i /***************found***************/ printf(\ printf(\ 第一空:j { int s[M][M]={{14,23,52,3}, {34,22,52,41}, {12,15,8,9}, {54,98,23,21}}; int im[M],sum; findmax(s,im); outdata(s,im);} findmax(int a[][M],int ln[]) { int i,j,t; for (i=0;i for(j=1;j /***************found***************/ ___1___; ln[i]=t; }} outdata(int(*a)[M],int *ln) { int i,j,sum; printf(\ /***************found***************/ ___2___; for(i=0;i { for (j=0;j printf(\ number\\n\ for (i=0;i /***************found***************/ {printf(\ sum=sum+ a[i][ln[i]]; } printf(\ 第一空:t=j;第二空:sum=0; 第三空:ln[i] 83.给定程序和功能是main函数读入数组a的各元素值,inver函数逆序后重新放置数组a元素的值。 #include void invert(int *s,int i,int j) { int t; if (i /***************found***************/ *(s+i)=___1___; *(s+j)=t; /***************found***************/ invert(s,___2___,j-1); }} main() { int a[N],i; for (i=0;i { printf(\ /***************found***************/ scanf(\ } invert(a,0,N-1); for (i=0;i printf(\ \ printf(\}?? 第一空:s[j] 第二空:i+1 第三空:a+i 84.给定程序的功能是:将无符号八进制数字构成的字符串转换为十进制整数。例如,输入的字符串为:556,则输入十进制整数366。 #include /***************found***************/ { char ___1___,s[6]; int n; p=s; gets(p); /***************found***************/ n=___2___; /***************found***************/ while(___3__!='\\0') n=n*8+*p-'0'; printf(\第一空:*p 第二空:*p-?0? 第三空:*(++p) 85.给定函数int MySearch(char *str,char *s)的功能是:统计字符串s在字符串str中出现的次数。例如,若输入字符串”12 123 12345”和”23”,则应输出2(表示字符串”23”在字符串”12 123 12345”中出现了两次)。若输入字符串”33333”和”33”,则应输出4(表示字符串”33”在字符串”33333”出现了四次)。 #include int MySearch( char* str, char* s ) { char* p; int n =0; for( ; *str; ) /***************found***************/ if( ( p = strstr( str, s ) ) != ___1___ ) { n++; str=p+1; } else /***************found***************/ ___2___; /***************found***************/ return( ___3___ );} main() { char str1[81], str2[21]; printf(\ gets(str1); printf(\ gets(str2); printf( \are(is) appeared in str1 %d times\\n\ 第一空:NULL 第二空:*str=0 第三空:n 86.给定程序中已建立一个带有头结点的单向链表,链表中的各结点按结点数据域中的数据从小到大顺序链接。函数fun的功能是:把形参x的值放入一个新结点并插入到链表中,插入后各结点仍保持从小到大顺序排列。 #include struct list *next; } SLIST; void fun( SLIST *h, int x) { SLIST *p, *q, *s; s=(SLIST *)malloc(sizeof(SLIST)); /**********found**********/ s->data=___1___; q=h; p=h->next; while(p!=NULL && x>p->data) { /**********found**********/ q=___2___; p=p->next; } s->next=p; /**********found**********/ q->next=___3___;} SLIST *creatlist(int *a) { SLIST *h,*p,*q; int i; h=p=(SLIST *)malloc(sizeof(SLIST)); for(i=0; i { q=(SLIST *)malloc(sizeof(SLIST)); q->data=a[i]; p->next=q; p=q;} p->next=0; return h;} void outlist(SLIST *h) { SLIST *p; p=h->next; if (p==NULL) printf(\ else { printf(\ do { printf(\ p=p->next; } while(p!=NULL); printf(\main() { SLIST *head; int x; int a[N]={11,12,15,18,19,22,25,29}; head=creatlist(a); printf(\ outlist(head); printf(\ \ scanf(\ fun(head,x); printf(\ outlist(head);} 第一空:x 第二空:p 第三空:s 87. 给定程序中,函数fun的功能是:读自然数1~10以及它们的平方根写到名为myufile3.txt的文本文件中,然后再顺序读出显示屏幕上。 #include { FILE *fp; int i,n; float x; if((fp=fopen(fname, \ return 0; for(i=1;i<=10;i++) /**********found**********/ fprintf(___1___,\ printf(\/**********found**********/ ___2___; printf(\/**********found**********/ if((fp=fopen(___3___,\ return 0; fscanf(fp,\ while(!feof(fp)) { printf(\ fscanf(fp,\ } fclose(fp); return 1;} main() { char fname[]=\ fun(fname);} 第一空: fp 第二空:fclose(fp) 第三空:fname 88.给定程序的功能是:调用fun函数建立班级通讯录。通讯录中记录每个学生的编号、姓名和电话号码。班级的人数和学生信息从键盘输入,每个人的信息作为一个数据块写到myfile5.dbf的二进制文件中。 #include 第一空:STYPE 第二空:FILE 第三空:fp 89.给定程序的功能是将十进制整数m转换成k进制(2≤k≤9)数的数字输出。例如,如果输入8和2,则应该输出1000。 #include #include { if( c>='A' && c<='Z') c=c+32; if(c>='a' && c<='u') /**************found**************/ c=c+___1___; else if(c>='v'&&c<='z') c=c-21; /**************found**************/ return ___2___ ;} main() { char c1,c2; printf(\ \ c1=getchar(); if( isupper( c1 ) ) { /**************found**************/ c2=fun(___3___); printf(\ c1,c2); } else printf(\第一空: 5 第二空:c 第三空:c1 92.给定程序的功能是求二分之一的圆面积,函数通过形参得到圆的半径,函数返回二分之一的圆面积。例如输入圆的半径值为:19.527输入为:s=598.95017。 #include {/**********found**********/ return 3.14159 * ___1___ /2.0;} main ( ) /**********found**********/ { ___2___ x; printf ( \ x: \/**********found**********/ scanf ( \ printf (\ 第一空:r*r 第二空:float 第三空:&x 93. 给定程序的功能是从字符串s尾部开始,按逆序把相邻的两个字符串交换位置,并一次把每个字符紧随其后重复出现一次,放在一个新串t中。例如,当s中的字符串为:”12345”是,则t中的字符串应为:”4455223311”。 #include void fun (char *s, char *t) { int i, j, sl; /************found************/ sl = ___1___; for (i=sl-1, j=0; i>=0; i-=2) { if (i-1 >= 0) t[j++] = s[i-1]; if (i-1 >= 0) t[j++] = s[i-1]; t[j++] = s[i]; t[j++] = s[i]; } /************found************/ ___2___;} main(){ char s[100], t[100]; printf(\/************found************/ scanf(\ fun(s, t); printf(\ 第一空:strlen(s) 第二空:t[j]=0; 第三空:s 94.给定程序的功能是将在字符串s中出现、而未在字符串t中出现的字符,构成一个新的字符串放在u中,u中字符按原字符串中字符顺序的逆序排列,不去掉重复字符。例如:当s中字符串为:“112345”时,t=“24677”时,u中的字符串应为:“5311”。 #include void fun (char *s, char *t, char *u) { int i, j, sl, tl, ul; char r, *up=u; sl = strlen(s); tl = strlen(t); for (i=0; i { for (j=0; j /************found************/ if (s[i] == t[j]) ___1___ ; /************found************/ if(j ___2___ tl) *u++ = s[i]; } *u = '\\0'; ul = strlen(up); for (i=0; i /************found************/ r = ___3___ ; up[i] = up[ul-1-i]; up[ul-1-i] = r; }} main(){ char s[100], t[100], u[100]; printf(\ scanf(\ printf(\ scanf(\ fun(s, t, u); printf(\ 第一空:break 第二空: == 第三空:up[i] 101.给定程序中已经建立一带有头结点的单项链表,链表中的各结点按照数据域递增有序链接。函数fun的功能是:函数链表中数据域值相同的结点,使之只保留一个。 #include struct list *next; } SLIST; void fun( SLIST *h) { SLIST *p, *q; p=h->next; if (p!=NULL) { q=p->next; while(q!=NULL) { if (p->data==q->data) { p->next=q->next; /**********found**********/ free(___1___); /**********found**********/ q=p->___2___; } else { p=q; /**********found**********/ q=q->___3___; } } }} SLIST *creatlist(int *a) { SLIST *h,*p,*q; int i; h=p=(SLIST *)malloc(sizeof(SLIST)); for(i=0; i { q=(SLIST *)malloc(sizeof(SLIST)); q->data=a[i]; p->next=q; p=q; } p->next=0; return h;} void outlist(SLIST *h) { SLIST *p; p=h->next; if (p==NULL) printf(\ else { printf(\ do { printf(\ p=p->next; } while(p!=NULL); printf(\main( ) { SLIST *head; int a[N]={1,2,2,3,4,4,4,5}; head=creatlist(a); printf(\list before deleting :\\n\outlist(head); fun(head); printf(\list after deleting :\\n\outlist(head); } 第一空: q 第二空:next 第三空:next 108.给定程序的功能是根据公式计算S,计算结果通过形参指针sn传回;n通过形参传入 Sn?11?13?15?17???12n?1例如:若n的值 为15时,输出的结果是:S=0.769788 N=15。 #include void fun(float *sn, int n) {/**************found**************/ int i,j=___1___; float s=0.0; for(i=0;i<=n;i++) { s=s+j*1.0/(2*i+1); j*=-1; } /**************found**************/ ___2___=s;} main(){ int n=15; float s; /**************found**************/ fun(___3___); printf(\ 第一空:1 第二空:*sn 第三空:&s,n 110.给定程序的功能是把一个字符串复制到另外一个字符串中。 void cpystr(char *ps,char *pd) { while(*ps!='\\0') { *pd=*ps; pd++; /******found******/ ___1___; } /******found******/ *pd=___2___;} main(){ char *pa=\b[20],*pb; pb=b; /******found******/ ___3___ printf(\ return 0;} 第一空:ps++ 第二空:?\\0?或0 第三空:cpystr(pa,pb);