计算机二级c语言上机 - 程序填空题

更新时间:2024-05-08 12:19:01 阅读量: 综合文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

程序填空题

1.给定程序中,函数fun的功能是:求出形参ss所指字符串数组中最长字符串的长度,其余字符串左边用字符*补齐,使其与最长的字符串等长。字符串数组中共有M个字符串,且串长 #include #define M 5 #define N 20 void fun(char (*ss)[N]) { int i, j, k=0, n, m, len; for(i=0; in) {

/**********found**********/ n=len; ___1___=i;} } for(i=0; i

/**********found**********/ for(j=___2___; j>=0; j--) ss[i][m--]=ss[i][j]; for(j=0; j

main(){char ss[M][N]={\\cchongqing\ i;

printf(\for(i=0; i

printf(\result:\\n\

for(i=0; i

printf(\参考答案

第一空:k 第二空len 第三空 ss[i][j]

2.给定程序中,函数fun的功能是:求ss所指字符串数组中长度最长的字符串所在的行下标,作为函数值返回,并把其串长放在形参n所指变量中。ss所指字符串数组中共有M个字符串,且串长 #define M 5 #define N 20

/**********found**********/

int fun(char (*ss) ___1___, int *n) { int i, k=0, len=0; for(i=0; i

/**********found**********/ if(i==0) *n=___2___; if(len>*n) {

/**********found**********/

___3___;

k=i; } } return(k);} main()

{ char ss[M][N]={\\cchongqing\ n,k,i;

printf(\ string are :\\n\ for(i=0;i

printf(\ %d\\n\printf(\ %s\\n\第一空: [N] 第二空:len 第三空 *n=len

3.函数fun的功能是:把形参a所指数组中最大值放在a[0]中,接着求出a所指数组中最小值放在a[1]中;再把a所指数组元素中的次大值放在a[2]中,把a数组元素中次小值放在a[3]中;其余依次类推。例如:若a所指数组中的数组最初排列为:1、4、2、3、9、6、5、8、7,则按规则移动后,数据排列为:9、1、8、2、7、3、6、4、5.形参n中存放a所指数组中数据的个数. #include #define N 9

/**********found**********/ void fun(int ___1___, int n) { int i, j, max, min, px, pn, t; /**********found**********/ for (i=0; i

/**********found**********/ for (j=___3___; j

{ max = a[j]; px = j; } if (min > a[j])

{ min = a[j]; pn = j; }} if (px != i)

{ t = a[i]; a[i] = max;

a[px] = t;

if (pn == i) pn= px; }

if (pn != i+1)

{ t = a[i+1]; a[i+1] = min; a[pn] = t; }}} main()

{ int b[N]={1,4,2,3,9,6,5,8,7}, i;

printf(\ :\\n\ for (i=0; i

printf(\ :\\n\for (i=0; i

第一空:*a或a[N] 第二空:2 第三空:i+1

4.给定程序的功能是:调用函数fun将指定源文件中的内容复制到指定的目标文件中,复制成功时函数返回值为1,失败时返回值为0。在复制过程中,把复制的内容输出到终端屏幕.主函数中源文件中入在变量sfname k ,目标文件名放在变量tfname中. #include

#include

int fun(char *source, char *target) { FILE *fs,*ft; char ch; /**********found**********/

if((fs=fopen(source, ___1___))==NULL) return 0;

if((ft=fopen(target, \ return 0;

printf(\ ch=fgetc(fs);

/**********found**********/ while(!feof(___2___)) { putchar( ch );

/**********found**********/ fputc(ch,___3___); ch=fgetc(fs); } fclose(fs); fclose(ft);

printf(\ 1;}

main(){char sfname[20] =\tfname[20]=\

FILE *myf; int i; char c; myf=fopen(sfname,\

printf(\ for(i=1; i<30; i++)

{c='A'+rand()%;fprintf(myf,\printf(\

fclose(myf);printf(\ if (fun(sfname, tfname))

printf(\ else printf(\

5.用筛选法可得到2~n(n<10000)之间的所有素数,方法是:首先从素数2开始,将所有2的倍数的数从数表中删去(把数表中相应位置的值置成0);接着从数表中找下一个非0数,并从数表中删去该数的所表倍数;依次类推,直到所找的下一个数等于n为止。这样会得一个序列:2,3,5,7,11,13,17,19,23??函数fun用筛选法找出所有小于等于n的素数,并统计素数的个数作为函数值返回。

#include int fun(int n)

{ int a[10000], i,j, count=0; for (i=2; i<=n; i++) a[i] = i; i = 2; while (i

/**********found**********/

for (j=a[i]*2; j<=n; j+=___1___) a[j] = 0; i++;

/**********found**********/ while (___2___==0) i++; }

printf(\ for (i=2; i<=n; i++)

/**********found**********/ if (a[i]!=___3___) {count++;

printf( count?\

return count;}

main(){ int n=20, r;r = fun(n);

printf(\ : %d\\n\第一空:a[i] 第二空:a[i] 第三空0

6.函数fun的功能是:从三个形参a,b,c中找出中间的那个数,作为函数值返回。例如:当a=3,b=5,c=4时,中数为4

#include

int fun(int a, int b, int c) { int t;

/**********found**********/

t = (a>b) ? (b>c? b :(a>c?c:___1___)) : ((a>c)?___2___ : ((b>c)?c:___3___)); return t;}

main(){ int a1=3, a2=5, a3=4, r; r = fun(a1, a2, a3);

printf(\ : %d\\n\第一空:a 第二空:a 第三空:b 7.函数fun的功能是:计算

f(x)?1?x?x2xn2!???n!

直到

xn?10?6n!。若x=2.5,函数值为:12.182494。 #include #include double fun(double x) { double f, t; int n;

/**********found**********/ f = 1.0+___1___; t = x; n = 1; do {

n++;

/**********found**********/ t *= x/___2___;

/**********found**********/ f += ___3___;

} while (fabs(t) >= 1e-6); return f;}

main(){ double x, y; x=2.5; y = fun(x);

printf(\

printf(\ y=%-12.6f \\n\第一空:x 第二空:n 第三空:t

8.给定程序中,函数fun的功能是:对形参ss所指字符串数组中的M个字符串按长度由短到长进行排序。ss所指字符串数组中共有M个字符串,且串长 #include #define M 5 #define N 20

void fun(char (*ss)[N])

{ int i, j, k, n[M]; char t[N]; for(i=0; i

/**********found**********/ for(j=___1___; jn[j]) ___2___; if(k!=i)

{ strcpy(t,ss[i]); strcpy(ss[i],ss[k]); /**********found**********/ strcpy(ss[k],___3___); n[k]=n[i]; } }} main()

{ char ss[M][N]={\\ int i;

printf(\ for(i=0; i

printf(\ for(i=0; i

第一空:i+1 第二空:k=j 第三空:t

9.函数fun的功能是:把形参a所指数组中的最小值放在元素a[0]中,接着把形参a所指数组中的最大值放在a[1]元素中;再把a所指数组元素中的次小值放在a[2]中,把a所指数组元素中的次大值放在a[3];其余以此类推。例如:若a所指数组中的数据最初排列为:9、1、4、2、3、6、5、8、7;则按规则移动后,数据排列为:1、9、2、8、3、7、4、6、5。形参n中存放a所指数组中数据的个数。

# include #define N 9

void fun(int a[], int n)

{ int i,j, max, min, px, pn, t; for (i=0; i

{/**********found**********/ max = min = ___1___; px = pn = i;

for (j=i+1; j

{ max = a[j]; px = j; } /**********found**********/ if (min>___3___)

{ min = a[j]; pn = j; } } if (pn != i)

{ t = a[i]; a[i] = min; a[pn] = t; if (px == i) px =pn; } if (px != i+1)

{ t = a[i+1]; a[i+1] = max; a[px] = t; } }}

main()

{ int b[N]={9,1,4,2,3,6,5,8,7}, i;

printf(\ :\\n\

for (i=0; i

printf(\ :\\n\ for (i=0; i

第一空:a[i] 第二空:a[j] 第三空:a[j]

10.给定程序中,函数fun的功能是:将形参std所指结构体数组中年龄最大者的数据作为函数值返回,并在main函数中输出。 #include typedef struct { char name[10]; int age; }STD;

STD fun(STD std[], int n) { STD max; int i; /**********found**********/ max= ___1___; for(i=1; i

/**********found**********/

if(max.age<___2___) max=std[i]; return max;} main( )

{ STD std[5]={\

\ }; STD max; max=fun(std,5); printf(\/**********found**********/

printf(\ Age : %d\\n\ ___3___,max.age);}

第一空:*std 第二空:std[i].age 第三空:max.name 11.给定程序中,函数fun的功能是:将s所指字符串中的所有数字字符移到所有非数字字符之后,并保持数字字符串和非数字字符串原有的先后次序。例如,形参s所指的字符串为:def35adh3kjsdf7。执行结果为:defadhkjsdf3537。 #include void fun(char *s) { int i, j=0, k=0; char t1[80], t2[80]; for(i=0; s[i]!='\\0'; i++)

if(s[i]>='0' && s[i]<='9'){ /**********found**********/ t2[j]=s[i]; ___1___; } else t1[k++]=s[i]; t2[j]=0; t1[k]=0;

/**********found**********/ for(i=0; i

for(i=0; i<___3___; i++) s[k+i]=t2[i];} main()

{ char s[80]=\ printf(\ string is : %s\\n\ fun(s);

printf(\ %s\\n\第一空:j++; 第二空:s[i]=t1[i];第三空:j

12.函数fun的功能是:把形参a所指数组中的奇数原顺序依次放到a[0]、a[1]、a[2]、??中,把偶数从数组中删除,奇数个数通过函数值返回。例如:若a所指数组中数据最初排列为:9、1、4、2、3、6、5、8、7,删除偶数后a所指数组中数据为:9、1、3、5、7,返回值为5。

#include #define N 9 int fun(int a[], int n) { int i,j; j = 0;

for (i=0; i

/**********found**********/ if (a[i]%2==___1___){ /**********found**********/ a[j] = a[i]; ___2___; } /**********found**********/ return ___3___;} main()

{ int b[N]={9,1,4,2,3,6,5,8,7}, i, n; printf(\ :\\n\ for (i=0; i

printf(\ : %d \\n\ printf(\ :\\n\ for (i=0; i

printf(\第一空:1 第二空:j++ 第三空j 13.给定程序中,函数fun的功能是:对形参s所指字符串下标为奇数的字符按ASCII码大小递增排序,并将排序后下标为奇数的字符取出,存入形参p所指字符数组中,形成一个新串。例如,形参s所指的字符串为:baawrskjghzlicda,执行后p所指字符数组中的字符串应为:aachjlsw。

#include

void fun(char *s, char *p) { int i, j, n, x, t; n=0;

for(i=0; s[i]!='\\0'; i++) n++; for(i=1; i

/**********found**********/ ___1___;

/**********found**********/

for(j=___2___+2 ; js[j]) t=j; if(t!=i) { x=s[i]; s[i]=s[t]; s[t]=x; }}

for(i=1,j=0; i

{ char s[80]=\ printf(\ %s\\n\ fun(s,p);

printf(\ %s\\n\第一空:t=i 第二空:i 第三空 0

14.给定函数int MySearch(char *str,char *s)的功能是:统计字符串s在字符串str中出现的次数。例如,若输入字符串”12 123 12345”和”23”,则应输出2(表示字符串”23”在字符串”12 123 12345”中出现了两次)。若输入字符串”33333”和”33”,则应输出4(表示字符串”33”在字符串”33333”出现了四次)。 #include #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

15.给定函数 char *MyDelete(char *str,char c)的功能是:在字符串str中删除变量c中的字符,有几个删几个,并返回所删字符的个数。例如,若输入字符串”ab abc bcdef”和字符?b?,则应输出字符串”a ac cdef”和3(表示删了3个字符?b?)。 #include #include

int MyDelete( char* str, char c ) { int i, j=0, k=0;

for( i = 0; str[i]; i++ ) if( str[i] != c )

/***************found**************/ { str[ j ]= str[i]; ___1___; } else k++;

/***************found**************/

str[j]=___2___ ;

/***************found**************/ return( ___3___ );} main(){

char string[81], x; ;

printf(\ gets(string);

printf(\ scanf(\

printf( \deleting %d '%c'(s), the string becomes:\\n%s\\n\第一空:j++ 第二空:0 第三空:k

16.给定程序中已建立一个带有头结点的单向链表,链表中的各结点按结点数据域中的数据从小到大顺序链接。函数fun的功能是:把形参x的值放入一个新结点并插入到链表中,插入后各结点仍保持从小到大顺序排序。 #include #include #define N 8 typedef struct list { int data;

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(\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

17.给定程序的功能是:调用函数fun将指定源文件中的内容复制到指定的目标文件中,复制成功时函数返回值为1,失败时返回值为0。在复制过程中,把复制的内容输出到终端屏幕。主函数中源文件名放在变量sfname中,目标文件名放在变量tfname中。 #include #include

int fun(char *source, char *target) { FILE *fs,*ft; char ch; /**********found**********/

if((fs=fopen(source, ___1___))==NULL) return 0;

if((ft=fopen(target, \ return 0;

printf(\ ch=fgetc(fs);

/**********found**********/ while(!feof(___2___)) { putchar( ch );

/**********found**********/ fputc(ch,___3___); ch=fgetc(fs); } fclose(fs); fclose(ft); printf(\ return 1;} main()

{ char sfname[20] =\

tfname[20]=\

FILE *myf; int i; char c; myf=fopen(sfname,\

printf(\ for(i=1; i<30; i++)

{c='A'+rand()%;fprintf(myf,\printf(\

fclose(myf);printf(\ if (fun(sfname, tfname)) printf(\ else printf(\

第一空: “r” 第二空:fs 第三空:ft

18.给定程序中,函数fun的功能是:读自然数1~10以及它们的平方根写到名为myfile3.txt的文本文件中,然后再顺序读出显示在屏幕上。 #include #include int fun(char *fname )

{ 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

19.给定程序的功能是:从键盘输入若干行文本(每行不超过80个字符),写到文件myfile4.txt中,用-1作为字符串输入结束的标志。然后将文件的内容读出显示在屏幕上。文件的读写分别由自定义函数ReadText和WriteText实现。

#include #include #include void WriteText(FILE *); void ReadText(FILE *); main()

{FILE *fp;

if((fp=fopen(\ { printf(\ } WriteText(fp); fclose(fp);

if((fp=fopen(\ { printf(\ } ReadText(fp); fclose(fp);}

/**********found**********/ void WriteText(FILE ___1___) { char str[81];

printf(\ gets(str);

while(strcmp(str,\/**********found**********/

fputs(___2___,fw); fputs(\ gets(str); }}

void ReadText(FILE *fr) { char str[81];

printf(\ fgets(str,81,fr); while( !feof(fr) ) {

/**********found**********/ printf(\ fgets(str,81,fr); }}

第一空:*fw 第二空:str 第三空:str

20.给定程序的功能是:调用fun函数建立班级通讯录。通讯录中记录每个学生的编号、姓名和电话号码。班级的人数和学生的信息从键盘读入,每个人的信息作为一个数据块写到myfile5.dbf的二进制文件中。 #include #include #define N 5 typedef struct { int num;

char name[10]; char tel[10]; }STYPE; void check();

/**********found**********/ int fun(___1___ *std){

/**********found**********/ ___2___ *fp; int i;

if((fp=fopen(\ return(0);

printf(\ for(i=0; i

/**********found**********/

fwrite(&std[i], sizeof(STYPE), 1, ___3___); fclose(fp); return (1);} main()

{ STYPE s[10]={ {1,\

{2,\ {4,\ int k; k=fun(s); if (k==1)

{ printf(\ check(); } else printf(\void check()

{ FILE *fp; int i; STYPE s[10]; if((fp=fopen(\ { printf(\

printf(\ printf(\ num name tel\\n\ for(i=0; i

{ fread(&s[i],sizeof(STYPE),1, fp);

printf(\ %s %s\\n\s[i].num,s[i].name,s[i].tel); }

fclose(fp);}

第一空:STYPE 第二空:FILE 第三空:fp

21.给定程序的功能是用冒泡法对6个字符进行排序 #include #define MAXLINE 20 fun ( char *pstr[6]) { int i, j ;char *p ;

for (i = 0 ; i < 5 ; i++ ) { for (j = i + 1; j < 6; j++) {

/**************found**************/ if(strcmp(*(pstr+i),___1___)>0) { p = *(pstr + i) ;

/**************found**************/ pstr[i] = ___2___ ;

/**************found**************/ *(pstr + j) = ___3___ ; }} }} main( ) { int i ;

char *pstr[6], str[6][MAXLINE] ; for(i = 0; i < 6 ; i++) pstr[i] = str[i] ;

printf( \

for(i = 0 ; i < 6 ; i++) scanf(\ fun(pstr) ;

printf(\

for(i = 0 ; i < 6 ; i++) printf(\第一空:*(pstr+j)或pstr[j] 第二空:*(pstr+j)或pstr[j] 第三空:p

22.给定程序的功能是将十进制整数m转换成k进制(2≤k≤9)数的数字输出。例如,如果输入8和2,则应该输出1000。 #include void fun( int m, int k ) { int aa[20], i;

for( i = 0; m; i++ ) {

/**********found**********/ aa[i] = ___1___;

/**********found**********/ m /= ___2___; } for( ; i; i-- )

/**********found**********/

printf( \main(){ int b, n;

printf( \ scanf( \ fun( n, b );}

第一空;m%k 第二空:k 第三空:aa

23.给定程序的功能是将未在字符串s中出现、而在字符串t中出现的字符,形成一个新的字符串放在u中,u中字符按原字符串中字符顺序排列,但是去掉重复字符。例如:当s=”12345”,t=”24677”,u中的字符为”67” #include #include

void fun (char *s, char *t, char *u) { int i, j, sl, tl, k, ul=0; sl = strlen(s); tl = strlen(t); for (i=0; i

{ for (j=0; j

if (t[i] == s[j]) break; if (j>=sl)

{ for (k=0; k=ul)

/************found************/ u[ul++] = ___2___ ; } }

/************found************/ ___3___='\\0';}

main(){ char s[100], t[100], u[100];

printf(\scanf(\

printf(\scanf(\ fun(s, t, u);

printf(\

第一空:break 第二空:t[i] 第三空:u[ul]

24.给定程序的功能是将在字符串s中出现、而未在字符串t中出现的字符形成一个新的字符串放在u中,u中字符按原字符串中字符顺序排列,不去掉重复字符。例如:当s=”112345”,t=”2467”时,u中的字符串为”1135”。

#include #include

void fun (char *s,char *t, char *u) { int i, j, sl, tl;

sl = strlen(s); tl = strlen(t); for (i=0; i

/************found************/ if (s[i] == t[j]) ___1___ ; if (j>=tl)

/************found************/ *u++ = ___2___; } /************found************/ ___3___ = '\\0';} main(){

char s[100], t[100], u[100];

printf(\ scanf(\

printf(\ scanf(\ fun(s, t, u);

printf(\

第一空:break 第二空:s[i] 第三空:*u

25.给定程序的功能是将在字符串s中下标为奇数位置上的字符,紧随其后重复出现一次,放在一个新串t中,t中字符按原字符串中字符出现的逆序排列(注意0为偶数)。例如:当s=”23516”,t=”1133”。

#include #include

void fun (char *s, char *t) { int i, j, sl; sl = strlen(s);

/************found************/ if(sl%2) sl-=2; ___1___ sl--; /************found************/ for (i=sl, j=___2___; i>=0; i-=2) { t[2*j] = s[i];

/************found************/ t[2*j +1] = ___3___ ; j++; } t[2*j]='\\0';}

main(){ char s[100], t[100];

printf(\

scanf(\ fun(s, t);

printf(\

第一空:else 第二空:0 第三空:s[i]或t[2*j]

26.给定程序的功能是将大写字母转换对应的小写字母的第五个字母;若小写字母v~z,使小写字母的值减去21。转换后的小写字母作为函数值返回。例如,若形参使字母A,则转换为小写字母f;若形参为字母W,则转换为小写字母b。 #include #include char fun(char c)

{ 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(\letter \\'%c\\' change to \\'%c\\'\\n\c1,c2); }

else printf(\第一空:5 第二空:c 第三空:c1

27.给定程序的功能是计算s=f(-n)+f(-n+1)+…+f(0)+f(1)+f(2)+ …f(n)的值。例如,当n为5时,函数值应该为:10.407143。

┌(x+1)/(x-2) x>0

f(x)= ┤0 x=0或x=2

└(x-1)/(x-2) x<0

#include #include float f( double x){

if (x == 0.0 || x == 2.0)

/************found************/ return ___1___; else if (x < 0.0)

return (x -1)/(x-2); else

return (x +1)/(x-2);} double fun( int n )

{ int i; double s=0.0, y;

/************found************/ for (i= -n; i<=___2___; i++) {y=f(1.0*i); s += y;}

/************found************/ return ___3___;}

main ( ){ printf(\第一空: 0 第二空:n 第三空:s

28.给定程序的功能是求二分之一的圆面积,函数通过形参得到圆的半径,函数返回二分之一的圆面积。例如输入圆的半径值为:19.527输入为:s=598.950017。 #include float fun ( float r )

{/**********found**********/ return 3.14159 * ___1___ /2.0;} main ( )

/**********found**********/ { ___2___ x;

printf ( \ x: \/**********found**********/ scanf ( \

printf (\

第一空:r*r 第二空:float 第三空:&x

29.给定程序的功能是将既在字符串s中出现、又在字符串t中出现的字符形成一个新字符串放在u中,u中字符按原字符串中字符顺序排列,但去掉重复字符。例如:当s=”42562”,t=”34”,u中的字符串为:”5”。 #include #include

void fun (char *s, char *t, char *u) { int i, j, sl, tl, k, ul=0;

sl = strlen(s); tl = strlen(t); for (i=0; i

{ for (j=0; j

if (s[i] == t[j]) break; if(j

{ for (k=0; k=ul)

/************found************/ u[ul++]=___2___ ; }} /************found************/ ___3___ = '\\0';}

main(){ char s[100], t[100], u[100];

printf(\ scanf(\

printf(\ scanf(\fun(s, t, u);

printf(\

第一空:== 第二空:s[i] 第三空:u[ul]

30.给定程序的功能是从字符串s尾部开始,按逆序把相邻的两个字符交换位置,并一次把每个字符紧随其后重复出现一次,放在一个新串t中。例如:当s中的字符串为:“12345”时,则t中的字符串应为:“4455223311”。 #include #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 31.给定程序的功能是将仅在字符串s中出现而不在字符中t中出现的字符,和仅在字符串t中出现而不在字符串s中出现的字符,构成一个新字符串放在u中,u中的字符按原字符串s中字符顺序排列,不去掉重复字符。例如:当s中字符串为:“112345”时,t=“24677”时,u中的字符串应为:“1135677”。 #include #include

void fun (char *s, char *t, char *u) { int i, j, sl, tl;

sl = strlen(s); tl = strlen(t); for (i=0; i

{ for (j=0; j

if (s[i] == t[j]) break; /************found************/ if (j ___1___ tl) *u++ = s[i]; } for (i=0; i

{ for (j=0; j

if (t[i] == s[j]) break; /************found************/ if (j ___2___ sl)

*u++ = t[i]; }

/************found************/ ___3___ = '\\0';} main()

{ char s[100], t[100], u[100];

printf(\ scanf(\

printf(\ scanf(\ fun(s, t, u);

printf(\第一空:== 第二空:=== 第三空:*u

32.给定程序的功能是将在字符串s中出现、而未在字符串t中出现的字符,构成一个新的字符串放在u中,u中字符按原字符串中字符顺序的逆序排列,不去掉重复字符。例如:当s中的字符串为:“112345”时,t=“24677”,u中的字符串应为:“5311” #include #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]

    33.给定程序的功能是计算并输入下列级数的前N项之和S(N),直到S(N+1)大于q为止,q的值通过形参传入

    S?N??21?32?43???N?1N例如:若q的值为50.0,则函数值为50.416687。 #include

    double fun( double q ) { int n; double s;

    n = 2; s = 2.0;

    /************found************/ while (s ___1___ q)

    { s=s+(double)(n+1)/n;

    /************found************/ ___2___ ; }

    printf(\

    /************found************/ ___3___ ;} main ( ){

    printf(\

    第一空:<= 第二空:n++; 第三空: return s

    34.给定程序的功能是求K!(K<13),并通过函数名传回主函数。例如:若K=10,则应该输入:3628800 。 #include long fun ( int k)

    {/************found************/ if (k ___1___ 0)

    /************found************/ return (k*fun(___2___)); /************found************/ else if ( k ___3___ 0 ) return 1L;} main()

    { int k = 10 ;

    printf(\第一空:> 第二空:k-1 第三空:==

    35.给定程序的功能是读入一个整数K(2≤k≤10000),打印它的所有质因子(就是所有为素数的因子)。例如:若输入整数:3410,则应输出:2、5、11、13。 #include IsPrime ( int n )

    { int i, m; m = 1;

    for ( i = 2; i < n; i++ ) /************found************/ if (!( n ___1___ i )) {

    /************found************/ m = 0; ___2___ ; } return ( m );} main( ){ int j, k;

    printf( \enter an integer number between 2 and 10000: \

    /************found************/ scanf( \

    printf( \ for( j = 2; j <= k; j++ )

    if( ( !( k%j ) )&&( IsPrime( j ) ) ) printf( \ printf(\

    第一空:% 第二空:break 第三空:&k

    36.给定程序的功能是分别统计字符串中大写字母和小写字母的个数。 #include

    void fun ( char *s, int *a, int *b ) { while ( *s ) { if ( *s >= 'A' && *s <= 'Z' ) /**********found**********/ ___1___ ;

    if ( *s >= 'a' && *s <= 'z' ) /**********found**********/ ___2___ ; s++; }}

    main( ){ char s[100]; int upper = 0, lower = 0 ;

    printf( \ \

    gets ( s );

    fun ( s, & upper, &lower ); /**********found**********/

    printf( \ lower = %d\\n\第一空: (*a)++ 第二空:(*b)++ 第三空:upper,lower 37.给定程序的功能是判断字符ch是否与串str中的某个字符相同;若相同,什么也不做,若不同,则插在串的最后。

    #include #include

    void fun(char *str, char ch )

    { while ( *str && *str != ch ) str++; /**********found**********/ if ( *str ___1___ ch ) { str [ 0 ] = ch;

    /**********found**********/ ___2___ = 0; }} main( ){ char s[81], c ;

    printf( \ gets ( s ); printf (\ c = getchar();

    /**********found**********/ fun(___3___) ;

    printf( \ is %s\\n\ s);} 第一空:!= 第二空:*(str+1)或*(++str) 第三空: s,c

    38.给定程序的功能是根据形参m(2≤m≤9),在二维数组中存放一张m行m列的表格,由main()函数输出。例如:若输入 3 则输出: 1 2 3

    2 4 6 3 6 9

    #include #define M 10

    int a[M][M] = {0} ; fun(int a[][M], int m) { int j, k ;

    for (j = 0 ; j < m ; j++ )

    for (k = 0 ; k < m ; k++ )

    /**************found**************/ ___1___ = (k+1)*(j+1);} main ( )

    { int i, j, n ;

    printf ( \ scanf (\

    /**************found**************/ fun ( ___2___ ) ;

    for ( i = 0 ; i < n ; i++)

    { for (j = 0 ; j < n ; j++)

    /**************found**************/ printf ( \ printf ( \

    第一空:a[j][k] 第二空:a,n 第三空:a[i][j]

    39.给定程序的功能是对a数组中n个人员的工资进行分段统计,各段的人数存到b数组中;工资为1000元以下的人数存到b[0]中, 工资为1000元到1999元的人数存到b[1]中, 工资为2000元到2999元的人数存到b[2], 工资为3000元到3999元的人数存到b[3], 工资为4000元到4999元的人数存到b[4],工资为5000元以上的人数存到b[5]中。例如,当a数组中的数据为:900、1800、2700、3800、5900、3300、2400、7500、3800,调用该函数后,b中存放的数据应是:1、1、2、3、0、2 #include

    void fun(int a[], int b[], int n) { int i;

    /**************found**************/ for (i=0; i<6; i++) b[i] = ___1___; for (i=0; i

    if (a[i] >= 5000) b[5]++;

    /**************found*************/ ___2___ b[a[i]/1000]++;} main()

    { int i, a[100]={ 900, 1800, 2700, 3800, 5900, 3300, 2400, 7500, 3800}, b[6]; fun(a, b, 9);

    printf(\

    /**************found**************/ for (i=0; i<6; i++)

    printf(\ printf(\

    第一空:0 第二空:else 第三空:b[i]

    40.给定程序的功能是将n个人员的考试成绩进行分段统计,考试成绩放在a数组中,各分数段的人数存到b数组中:成绩为60到69的人数存到b[0], 成绩为70到79的人数存到b[1], 成绩为80到89的人数存到b[2], 成绩为90到99的人数存到b[3],成绩为100的人数存到b[4],成绩为60分以下的人数存到b[5]中。例如,当a数组中的数据是:93、85、77、68、59、43、94、75、98。调用该函数后,b数组中存放的数据应是:1、2、1、3、0、2。 #include

    void fun(int a[], int b[], int n) { int i;

    for (i=0; i<6; i++) b[i] = 0;

    /**************found**************/ for (i=0; i< ___1___; i++) if (a[i] < 60) b[5]++;

    /**************found**************/ ___2___ b[(a[i]- 60)/10]++;} main() { int i, a[100]={ 93, 85, 77, 68, 59, 43, 94, 75, 98}, b[6];

    /**************found**************/ fun(___3___, 9);

    printf(\

    for (i=0; i<6; i++) printf(\ printf(\

    第一空:n 第二空:else 第三空:a,b

    41.给定程序的功能是求出1到1000之内能被7或11整除但不能同时被7和11整除的所有整数放存数组a中,通过n返回这些数的个数。 #include void fun(int *a, int *n) { int i, j = 0 ;

    for(i = 1 ; i <= 1000 ; i++) {

    /**************found**************/

    if(((i % 7 == 0) || (i % 11 == 0)) && i % 77 != 0) a[j++] = ___1___ ; }

    /**************found**************/ *n = ___2___ ;} main()

    { int aa[1000], n, k ;

    /**************found**************/ fun ( ___3___ ) ;

    for ( k = 0 ; k < n ; k++ )

    if((k + 1) % 10 == 0) printf(\ else printf(\第一空:i 第二空:j 第三空:aa,&n

    42.给定程序中已经建立一个带有头结点的单向链表,在main函数中将多次调用fun函数,每调用一次fun函数,输出链表尾部结点中的数据,并释放该结点,使链表缩短。

    #include #include #define N 8 typedef struct list { int data;

    struct list *next; } SLIST;

    void fun( SLIST *p) { SLIST *t, *s;

    t=p->next; s=p; while(t->next != NULL) { s=t;

    /**********found**********/ t=t->___1___; }

    /**********found**********/ printf(\ s->next=NULL;

    /**********found**********/ free(___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]={11,12,15,18,19,22,25,29}; head=creatlist(a);

    printf(\ outlist(head);

    printf(\while (head->next != NULL){ fun(head); printf(\printf(\from head again :\\n\outlist(head); }}

    第一空:next 第二空:t->data 第三空:t

    43.给定程序的功能是计算score中m个人的平均成绩aver,将低于aver的成绩放在below中,通过函数名返回人数。例如,当

    socre={10,20,30,40,50,60,70,80,90},m=9时,函数返回的人数应该是4,below={10,20,30,40}。 #include #include

    int fun(int score[], int m, int below[]) { int i, j = 0 ; float aver = 0.0 ;

    for(i = 0 ; i < m ; i++) aver += score[i] ; aver /= (float) m ; for(i = 0 ; i < m ; i++)

    /**************found**************/

    if(score[i] < aver) below[j++] = ___1___ ; return j ;}

    main(){ int i, n, below[9] ;

    int score[9] = {10, 20, 30, 40, 50, 60, 70, 80, 90} ;

    /**************found**************/ n = fun(score, 9, ___2___) ;

    printf( \/**************found**************/

    for (i = 0 ; i < n ; i++) printf(\第一空:score[i] 第二空:below 第三空:below[i]

    44.给定程序的功能是求出能整除x且不是偶数的各整数,并放在数组pp中,这些除数的个数由n返回。例如,若x的值为30,则有4个数符合要求,它们是1,3,5,15。 #include void fun(int x, int pp[], int *n) { int i, j = 0 ;

    for(i = 1 ; i <= x ; i +=2 )

    /**************found**************/ if((x % i) == 0) pp[j++] = ___1___ ; /**************found**************/ *n = ___2___ ;}

    main(){ int x, aa[1000], n, i ;

    printf( \enter an integer number:\\n\) ; scanf(\

    /**************found**************/ fun(x, ___3___ ) ;

    for( i = 0 ; i < n ; i++ ) printf(\ printf(\

    第一空: i 第二空: j 第三空:aa,&n

    45.已知学生的记录由学号和学习成绩构成,N名学生的数据已经存入a结构体数组中。给定程序的功能是找出成绩最低的学生记录,通过形参返回主函数。 #include #include #define N 10 typedef struct ss

    { char num[10]; int s; } STU; fun(STU a[], STU *s)

    {/**************found**************/ ___1___ h; int i ; h = a[0];

    for ( i = 1; i < N; i++ )

    /**************found**************/ if ( a[i].s < h.s ) ___2___ = a[i]; /**************found**************/ *s = ___3___ ;}

    main(){STU a[N]={ {\

    {\ {\{\ ; int i;

    printf(\ for ( i=0; i< N; i++ )

    printf(\ Mark = %d\\n\ fun ( a, &m );

    printf (\ RESULT *****\\n\

    printf (\ : %s , %d\\n\ 第一空:STU 第二空:h 第三空:h

    46.给定程序中已经建立一个带有头结点的单项链表,链表中的各结点按照数据域递增有序链接。函数fun的功能是:函数链表中数据域值相同的结点,使之只保留一个。

    #include #include #define N 8 typedef struct list { int data;

    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

    47.给定程序的功能是实现矩阵(3行3列)的转置。#include int fun(int array[3][3]) { int i,j,arr[3][3] ;

    memcpy(arr, array, 9*sizeof(int)) ; for(i = 0 ; i < 3 ; i++) for(j = 0 ; j < 3 ; j++)

    /**************found**************/ array[i][j] = ___1___ ;} main(){ int i,j;

    int array[3][3]={{100,200,300}, {400,500,600}, {700,800,900}}; for (i=0;i<3;i++)

    { for (j=0;j<3;j++)

    printf(\ printf(\

    /**************found**************/ fun(___2___);

    printf(\ for (i=0;i<3;i++)

    { for (j=0;j<3;j++)

    /**************found**************/ printf(\ printf(\

    第一空:arr[j][i] 第二空:array 第三空:array[i][j] 48.函数fun的功能是:统计长整数n的各个位上出现数字1、2、3的次数,并通过上部(全局)变量 c1、c2、c3返回主函数。例如:当n=123114350时,结果应该是:c1=3 c2=1 c3=2。 #include int c1,c2,c3; void fun(long n) { c1 = c2 = c3 = 0; while (n) {

    /**********found**********/ switch(___1___){

    /**********found**********/ case 1: c1++;___2___; /**********found**********/ case 2: c2++;___3___; case 3: c3++; }

    n /= 10;}}

    main(){ long n=123114350L;

    fun(n); printf(\

    printf(\ c1=%d c2=%d c3=%d\\n\n,c1,c2,c3);}

    第一空:n 第二空:break 第三空:break

    49.函数fun的功能是进行字母转换,若形参ch中小写英文字母,则转换成参应的大写英文字母;若ch中是大写英文字母,则转换成对应的小写英文字母;若是其它字母则保持不变;并转换后的结果作为函数值返回。#include #include char fun(char ch)

    {/**********found**********/ if ((ch>='a')___1___(ch<='z')) return ch -'a' + 'A'; if ( isupper(ch) )

    /**********found**********/ return ch +'a'-___2___ ; /**********found**********/ return ___3___;} main(){ char c1, c2;

    printf(\ :\\n\ c1='w'; c2 = fun(c1);

    printf(\ c2=%c\\n\ c1='W'; c2 = fun(c1);

    printf(\ c2=%c\\n\ c1='8'; c2 = fun(c1);

    printf(\ c2=%c\\n\第一空:&& 第二空:?A? 第三空:ch

    50.给定程序的功能是对指定字符在字符串a中出现的次数进行统计,统计的数据存到b数组中。其中:字符?Z? 出现的次数存放到b[0]中,字符?Y?出现的次数存放到b[1],字符?X?出现的次数存放到b[2]中,字符?W?出现的次数存放到b[3],字符?V?出现的次数存放到b[4]中,其它字符出现的次数存到b[5]中。 #include #include

    void fun(char *a, int b[]) { int i;

    for (i=0; i<6; i++) b[i] = 0;

    /**************found**************/ for (i=0; i< ___1___(a); i++)

    if (a[i] >= 'V' && a[i] <= 'Z') b[4-(a[i]-'V')]++;

    /**************found**************/ ___2___ b[5]++;} main()

    { int i, b[6];

    char a[100] = \/**************found**************/ fun(___3___);

    printf(\

    for (i=0; i<6; i++) printf(\ printf(\

    第一空:strlen 第二空:else 第三空:a,b

    50.函数fun的功能是:将形参a所指数组中的前半部分元素中的值和后半部分元素中的值对换。形参n中存放数组中的数据的个数,若n为奇数,则中间的元素不动。例如:若a所指数组中的数据一次为:1、2、3、4、5、6、7、8、9,则调换后为:6、7、8、9、5、1、2、3、4。

    #include #define N 9

    void fun(int a[], int n) { int i, t, p;

    /**********found**********/

    p = (n%2==0)?n/2:n/2+___1___; for (i=0; i

    /**********found**********/ a[i] = a[p+___2___]; /**********found**********/ ___3___ = t; }} main()

    { int b[N]={1,2,3,4,5,6,7,8,9}, i;

    printf(\ :\\n\ for (i=0; i

    第一空:1 第二空:i 第三空:a[p+i]

    52.给定程序的功能是把s串中所有的字符前移一个位置,串中的第一个字符移到最后。例如:s串中原有的字符串为:Mn.123xyZ,则调用函数后,s串中的内容为:n.123xyZM

    #include #define N 81 fun ( char *s ) { char b[N] ;

    sprintf(b, \

    /**************found**************/ strcpy(___1___) ;} main( )

    { char a[ N ] ;

    printf ( \ a string : \ printf ( \ \/**************found**************/ fun ( ___2___ );

    printf ( \ \/**************found**************/ ___3___ ( a );}

    第一空:s,b 第二空:a 第三空:puts

    53.给定程序的功能是计算并输出high以内最大的10个素数和。high由主函数传给fun函数。例如:high值为100,函数的值为732。 #include #include int fun( int high )

    { int sum = 0, n=0, j, yes;

    /************found************/ while ((high >= 2) ___1___ (n < 10)) { yes = 1;

    for (j=2; j<=high/2; j++ ) if (high % j ==0 ){

    /************found************/ yes=0; ___2___; }

    if (yes) { sum +=high; n++; } /************found************/ ___3___; } return sum ;} main ( ){

    printf(\

    第一空:&& 第二空:break 第三空:high=high-1 54.给定程序的功能是删除w数组中下标为k的元素中的值。程序中,调用了getindex、arrout和arrdel三个函数,getindex用以输入所删除元素的下标,函数中对输入的下标进行检查,若越界,则要求重新输入,直到正确为止。arrout用以输出数组中的数据,arrdel进行所要求的删除操作。 #include #define NUM 10 arrout ( int *w, int m )

    { int k;

    /************found************/ for (k = 0; k < ___1___; k++) printf (\ printf (\

    arrdel ( int *w, int n, int k ) { int i;

    for ( i = k; i < n-1; i++ ) w[i] = w[i+1]; n--;

    /************found************/ return ___2___;} getindex( int n ) { int i;

    /************found************/ ___3___

    { printf(\ scanf (\

    } while( i < 0 || i > n-1 ); return i;} main( )

    { int n, d,

    a[NUM]={21,22,23,24,25,26,27,28,29,30}; n = NUM;

    printf (\ arrout ( a, n );

    d = getindex( n ); n = arrdel ( a, n, d );

    printf (\ arrout( a, n );}

    第一空:m 第二空:n 第三空: do

    55.给定程序的功能是从字符串s尾部开始,按逆序把在其中出现的每相邻的两个字符,紧随其后重复出现一次,放在一个新串t中,若字符串s中头部有剩余的单个字符也重复,放在t的最后。例如:当s中的字符串为:”12345”时,则t中的字符串应该为:”5454323211” #include #include

    void fun (char *s, char *t) { int i, j, sl; sl = strlen(s);

    for(i=sl-1,j=0;i>=0;i-=2) { t[j++] = s[i];

    if (i-1 >= 0) t[j++] = s[i-1]; /************found************/ t[j++] = ___1___;

    /************found************/ if (i-1 ___2___ 0) t[j++]=s[i-1]; } t[j] = '\\0';} main()

    { char s[100], t[100];

    printf(\/************found************/ fun(___3___);

    printf(\第一空:s[i] 第二空:>= 第三空:s,t 56. 给定程序的功能是建立一个带有头结点的单向链表,并用随机函数为各结点赋值。函数fun的功能是将单向链表结点(不包括结点)数据域为偶数的值累加起来,并且作为函数值返回。 #include #include typedef struct aa

    { int data; struct aa *next; }NODE; int fun(NODE *h) { int sum = 0 ;

    /***********found**********/ ___1___ *p;

    /***********found**********/ p=___2___; while(p)

    { if(p->data%2==0) sum +=p->data;

    /***********found**********/ p=___3___; } return sum;}

    NODE *creatlink(int n) { NODE *h, *p, *s, *q; int i, x;

    h=p=(NODE *)malloc(sizeof(NODE)); for(i=1; i<=n; i++)

    { s=(NODE *)malloc(sizeof(NODE)); s->data=rand(); s->next=p->next; p->next=s; p=p->next; } p->next=NULL; return h;}

    outlink(NODE *h, FILE *pf) { NODE *p; p = h->next;

    fprintf(pf ,\ LIST :\\n\\n HEAD \ while(p)

    { fprintf(pf ,\ fprintf (pf,\outresult(int s, FILE *pf)

    {fprintf(pf,\ %d\\n\main(){ NODE *head; int even; head=creatlink(12); head->data=9000; outlink(head , stdout); even=fun(head);

    printf(\ result :\\n\ outresult(even, stdout);}

    第一空:NODE 第二空:h->next 第三空:p->next 57.给定程序的功能是把在字符串s中出现的每个字符,紧随其后重复出现一次,形成一个新串放在t中,且在t中把原相邻字符的位置进行了互换。例如:当s中的字符串为:”12345”时,则t中的字符串应该为:”2211443355”。 #include #include

    void fun (char *s, char *t) { int i,j,sl;

    /************found************/ sl = ___1___(s);

    for (i=0, j=0; i

    { t[2*j] = s[i+1]; t[2*j +1] = s[i+1];

    j++; }

    t[2*j] = s[i]; t[2*j +1] = s[i]; /************found************/ ___2___; } t[2*sl] = '\\0';} main()

    { char s[100], t[100];

    printf(\/************found************/ fun(___3___);

    printf(\

    第一空:strlen 第二空:j=j+1 第三空:s,t

    58.给定程序的功能是根据公式求P的值,结果由函数值带回。m与n为两个正整数且要求m>n。

    P?m!n!(m?n)!

    例如:m=11,n=4时,运行结果为

    330.000000。

    #include long jc(int m)

    { long s=1; int i ;

    /**************found**************/ for(i=1;i<=m;i++) s=___1___ ; return s;}

    float fun(int m, int n) { float p;

    /**************found**************/ p=1.0*jc(m)/jc(n)/jc(___2___) ;

    /**************found**************/ ___3___;}

    main(){ printf(\第一空:s*i 第二空:m-n 第三空:return p

    59.给定程序的功能是把a数组中的n个数,和b数组中逆序的n个数一一对应相乘求平方,结果存在c数组中。例如:当a数组中的值是:1、3、5、7、8,b数组中的值是:2、3、4、5、8,c中存放的数据是:64、225、400、441、256。 #include

    void fun(int a[], int b[], int c[], int n) { int i;

    for (i=0; i

    /**************found**************/ _1___ = (a[i] * b[n-1-i]) *(a[i] * b[n-1-i]);} main()

    { int i, a[100]={1,3,5,7,8},

    b[100]={2,3,4,5,8}, c[100];

    /**************found**************/ fun(___2___, 5);

    printf(\

    /**************found**************/

    for (i=0; i<5; i++) printf(\ printf(\

    第一空:c[i] 第二空:a,b,c 第三空:c[i]

    60.给定程序的功能是根据公式计算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

    61.给定程序的功能是把s 串中所有的字母改写该字母的下一个字母,字母z改写成字母a。大写字母仍为大写字母,小写字母仍为小写字母,其它字符不变。 #include #include #include #define N 81 fun ( char *s )

    {/**************found**************/ char *p = ___1___ ; while(*p) {

    /**************found**************/ if(*p == 'Z') *p = ___2___ ;

    /**************found**************/ else if(*p == 'z') *p = ___3___ ; else if(isalpha(*p)) *p = (*p) + 1 ; p++ ; }}

    main( ){ char a[N];

    printf ( \ \

    printf ( \ \ fun ( a );

    printf ( \ \ puts ( a );}

    第一空:s 第二空:?A?或65 第三空:?a?或97

    62.给定程序中,函数fun的功能是:有N×N矩阵,根据给定的m(m

    个位置,左边置为0。例如,N=3,m=2,则下列矩阵 1 2 3 程序执行结果为 0 0 1 4 5 6 0 0 4 7 8 9 0 0 7 #include #define N 4

    void fun(int (*t)[N], int m) { int i, j;

    /**********found**********/ for(i=0; i=0; j--) /**********found**********/ t[i][j+___2___ ]=t[i][j]; /**********found**********/ for(j=0; j<___3___; j++) t[i][j]=0; }} main()

    { int t[][N]={21,12,13,24,25,16,47,

    38,29,11,32,54,42,21,33,10}, i, j, m; printf(\ for(i=0; i

    printf(\ \ printf(\ }

    printf(\ \scanf(\ fun(t,m);

    printf(\ for(i=0; i

    printf(\ \ printf(\ }}

    第一空:i++ 第二空:m 第三空:m

    63.给定程序的功能是建立一个带有头结点的单向链表,并用随机函数为各结点赋值。函数fun的功能查找结点数据域最大值,并且作为函数值返回。 #include #include typedef struct aa

    { int data; struct aa *next; }NODE; int fun(NODE *h) { int max = 0 ;

    /***********found**********/ ___1___ *p; p=h->next;

    /***********found**********/ max=___2___ while(p)

    { if(p->data>max) max=p->data;

    /***********found**********/ ___3___ } return max;}

    NODE *creatlink(int n) { NODE *h, *p, *s, *q; int i, x;

    h=p=(NODE *)malloc(sizeof(NODE)); for(i=1; i<=n; i++)

    { s=(NODE *)malloc(sizeof(NODE)); s->data=rand(); s->next=p->next; p->next=s; p=p->next; } p->next=NULL; return h;}

    outlink(NODE *h, FILE *pf) { NODE *p; p = h->next;

    fprintf(pf ,\ LIST :\\n\\n HEAD \ while(p)

    { fprintf(pf ,\ fprintf (pf,\}

    outresult(int s, FILE *pf)

    {fprintf(pf,\ %d\\n\main()

    { NODE *head; int even; head=creatlink(12); head->data=9000; outlink(head , stdout); even=fun(head);

    printf(\ result :\\n\ outresult(even, stdout);}

    第一空:NODE 第二空:p->data 第三空:p=p->next 64.给定程序的功能是把一个字符串的字符复制到另外一个字符串中。

    void cpystr(char *ps,char *pd) { while(*ps!='\\0') { *pd=*ps; pd++;

    /******found******/ ___1___; } /******found******/ *pd=___2___;} main(){

    char *pa=\ pb=b;

    /******found******/ ___3___

    printf(\ return 0;}

    第一空:ps++ 第二空:?\\0?或0 第三空:strcpy(pa,pb); 65.给定程序的功能是:从键盘输入一个字符串(长度不超过80个字符),依次扫描字符串中的小写字母o,每次将小写字母o的左右字符串部分作交叉换位,即左边字符串移到小写字母o的右边,而原先右边的则返之。并把小写字母o删除,依次直至小写字母o处理完,之后已处理的字符串出到屏幕。例如:输入字符串为:”123oabco98”,处理后输出为”98123abc”。 #include

    #include void main()

    {int i=0,j=0,sj=0,bs; char ch[80]; char *s,*f;

    printf(\ scanf(\ while (ch[i]!='\\0') {

    /******found******/ if ___1___ {sj++;}

    /******found******/ ___2___; } for (i=0;i

    strcat(f,s); strcpy(ch,f); }

    printf(\

    第一空:(ch[i]==?o?) 第二空:i++ 第三空:break 66.给定程序的功能是:从键盘输入一个字符串(长度不超80个字符),依次扫描字符串的小写字母o,每次将小写字母o左侧所有小写字母转换为大写字母,大写字母转换为小写字母。并把小写字母o删除,依次直至小写字母o处理完,之后把已处理的字符串输出到屏幕。例如:输入字符串为”aA1BoCao”,处理后输出为”aA1BcA”。输入字符串”aAobC”,输出为”AabC”。 #include #include void main()

    {int i=0,j=0,nulin,sj=0,m; char ch[80];

    printf(\ scanf(\ while (ch[i]!='\\0') { if (ch[i]=='o') sj++; i++; } for (i=0;i

    /***************found***************/ ___1___;

    for (m=0;m

    {if (ch[m]>='a' && ch[m]<='z') ch[m]=ch[m]-32; /***************found***************/ ___2___

    if (ch[m]>='A' && ch[m]<='Z') ch[m]=ch[m]+32; } if (m>=j)

    ch[m]=ch[m+1]; }

    /***************found***************/ ___3___;}

    printf(\

    第一空:nulin=strlen(ch); 第二空:else 第三空:ch[nulin-1]=?\\0?;

    67. 给定函数countValue(int n),它的功能是:求n以内(不包括n)同时被3与7整除的所有自然数之和的平方根s,s作为函数返回值。主程序调用该函数输出n为1000时的函数值153.909064。 #include #include /******found******/

    ___1___ countValue(int n) { double xy=0.0; int i;

    /******found******/ for(i=8;__2___;i++)

    if(i%3==0&&i%7==0) xy+=i; xy=sqrt((double)xy); /******found******/ ___3___;} main()

    { printf(\

    第一空:double 第二空:i #include

    double countValue(int n) /******found******/ { ___1___xy=0.0; int i;

    for(i=1;i

    if(i==0&&i%7==0) /******found******/ ___2___; return xy;} main(){

    /******found******/

    printf(\

    第一空:double 第二空:xy=xy+sqrt((double)i) 第三空:countValue(1000)

    69.给定程序的功能分别求7个学生三门课程的平均成绩,在主程序中输出各学生平均成绩和最大平均成绩av。

    #include #include

    float fun(float a,float b,float c) { float sum,aver; sum=a+b+c;

    /**********found************/ ___1___; return(aver);}

    main(){ float a[7][3]={{80,90.5,81.5}, {70,69.8,90.5}, {68,97,99.0}, {86.5,89,95}, {78,96,90}, {87.5,89,92}, {64.5,80,78}}; float av=0.0,b[7];int i; for (i=0;i<7;i++)

    /**********found************/ {b[i]=___2___;

    /**********found************/ if ___3___ av=b[i];} for (i=0;i<7;i++)

    printf(\ printf(\

    第一空:aver=sum/3.0 第二空:b[i]=fun(a[i][0],a[i][1],a[i][2]); 第三空:if(av

    70.给定程序的功能是用递归法计算n!。用递归方法计算n!,可使用如下公式表示

    ┌1 (n=0,1) n!= ┤

    └n×(n-1)!(n>1) #include long ref(int n) { long m;

    if (n<0) printf(\/************found************/ else if (___1___) m=1;

    /************found************/ else ___2___; return(m);}

    main(){ int n; long y;

    printf(\/************found************/ scanf(\ y=ref(n);

    printf(\ return;} 第一空:(n==0||n==1)第二空:m=ref(n-1)*n 第三空:&n

    71.给定程序的功能是求出数组中的最大数max及最大数的个数cnt数组xx中值能被3整除或能被7整除的算术平均值pj(保留职位小数),结果max,cnt,pj输出到屏幕。

    #include #define N 20 void main() { int max;

    int cnt,xx[N]={78,43,56,34,43,32,85, 43,46,10,90,34,90,3,52,61,42,89,90,54}; float pj;

    long j=0; int I,k;

    /*************found************/ ___1___

    /*************found************/ for(___2___;I

    /*************found************/ {if (xx[I]>max) ___3___;

    if (xx[I]%3==0||xx[I]%7==0) {j+=xx[I];k++;} } for (I=0,cnt=0;I

    printf(\max,cnt,pj);}??

    第一空:max=xx[0];第二空: for(i=0,k=0;i

    72.给定程序的功能是找出所有100以内(含100)满足I,I+4,I+10都是素数的整数I(I+10也以100以内)的个数cnt以及这些I之和sum。 #include int cnt,sum;

    int isPrime(int number) { int i,tag=1;

    if(number==1) return 0;

    for(i=2;tag&&i<=number/2;i++)

    /***************found***************/ if(___1___) tag=0; return tag;} void countValue()

    { int I,count=0,xx[30]; int j,k,m;

    cnt=0; sum=0;

    /***************found***************/ for(I=1;___2___;I++)

    if(isPrime(I)) {xx[count]=I;count++;} for(I=0;I

    if (isPrime(xx[I]+4)&&isPrime(xx[I]+10)) /***************found***************/ {___3___;}}

    void main(){ cnt=sum=0;

    countValue();printf(\ printf(\

    第一空:number%i==0 第二空:I<90 第三空:cnt++;sum+=xx[I]

    73.给定程序的功能是对从键盘输入的字符数组xx(不超过80个字符),按字符从大到小的顺序进行排序,排序后的结果存入字符串数组xx中。例如:输入:dAe,BfC.结果:fedCBA. #include void main()

    { char xx[80] ;

    int numi,numj; char ch;

    printf(\ scanf(\

    for (numi=0;numi

    /***************found***************/ for (numj=___1___;numj

    /***************found***************/

    ___2___;

    xx[numi]=xx[numj];

    /***************found***************/

    ___3___;}

    printf(\

    第一空:numi+1 第二空:ch=xx[numi] 第三空:xx[numj]=ch

    74.给定程序的功能是:对字符数组xx中字符按给定的替代关系对所有字符进行替代,仍存入数组xx的对应的位置上。替代关系:f(p)=p*11 mod 256(p是数组xx中某一个字符的ASCII值,f(p)是计算后新字符的ASCII值),如果原字符是大写字母或计算后f(p)值小于等于32, 则该字符不变,否则将f(p)所对应的字符进行替代。

    #include #include void main() { char xx[80]; int i,j;

    printf(\ scanf(\

    /***************found***************/ for (i=0;___1___;i++)

    if((('A'<=xx[i])&&(xx[i]<='Z'))|| (((xx[i]*11) % 256 )<=32))

    /***************found***************/ ___2___ else

    /***************found***************/ xx[i]=___3___;

    printf(\

    第一空:i

    #include struct stu_list { int num;

    char name[20]; char sex; float score;

    }s[5]={{9801,\

    {9802,\ {9803,\ {9804,\ {9805,\main() { int i,c=0;

    float ave,sum=0; for (i=0;i<5;i++) {

    /***************found***************/ sum+=___1___;

    /***************found***************/ if (___2___) c+=1;}

    printf(\

    /***************found***************/ ___3___;

    printf(\ return; } ?? 第一空:sum+=s[i].score 第二空:if(s[i].score<60) c+=1 第三空:ave=sum/5;

    76.给定程序的功能是在三位整数(100至999)中寻找符合下面条件的整数,并依次从小到大存入数组b[]中;它既是完全平方数,又有两位数相同,例如144,676等。函数int jsValue(int n)判断参数是否满足该条件,如果满足该条件函数返回值为1,否则返回值为0。 #include int jsValue(int n) { int j,k=0;

    int n1,n2,n3; j=10; while(j*j<=n) { if (n==j*j) { n1=n / 100;

    /***************found***************/ n2=___1___; n3=n % 10; if(n1==n2||n1==n3||n2==n3) k=1; }

    /***************found***************/ ___2___; } return k;} main()

    { int b[20],num,i;

    for (i=100,num=0;i<=999;i++) if (jsValue(i)==1) { b[num]=i;

    /***************found***************/ ___3___; } for (i=0;i

    printf(\第一空:(n/10) 第二空:j++; 第三空:num++; 77.给定程序的功能是从键盘输入3行3列矩阵的各个元素,然后输出对角线元素之和。 #include int fun()

    { int a[3][3],sum; int i,j;

    /***************found**************/ sum=___1___; for (i=0;i<3;i++) {for (j=0;j<3;j++)

    /***************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 double fun(int n) { int a,b,c,k; double s; s=0.0; a=2; /***************found***************/ ___1___; for (k=1;k<=n;k++) { s=s+(double)a/b; c=a; a=a+b;b=c; } /***************found***************/ ___2___;} main(){ int n; /***************found***************/ printf(\ scanf(\ ; printf(\第一空:b=1第二空:return s 第三空:&n 79.给定程序的功能是读入五位用户的姓名和电话号码,按姓名的字典顺序排列后,输出用户的姓名和电话号码。函数getdata读入五位用户的姓名和电话号码。getsort函数把数据按姓名的字典顺序排序。outdata输出最后的结果。 #include #define N 5 typedef struct { char name[20]; char num[10]; }USER; /***************found***************/ getdata(___1___) { int i; printf(\ for(i=0;i

    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 #define N 5 typedef struct { char name[20]; char num[10]; }USER; getdata(USER *sp) { int i; printf(\ for(i=0;i0) k=j; temp=sp[k]; /***************found***************/ ___2___; /***************found***************/ ___3___; }} outdata(USER *sp) { int i; printf(\ for (i=0;i

    第一空:USER temp 第二空:sp[k]=sp[i]; 第三空:sp[i]=temp;

    81.给定程序的功能是找出方阵中每列最小元素以及所在的行号。函数findmin找出每列中最小元素所在行号,函数outdata输出方阵中每列最小元素及其所在行号。

    #include #include #define M 4 main()

    { 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 #include #define M 4 main()

    { 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;ja[i][t])

    /***************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 #define N 10

    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 main()

    /***************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 #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 #include #define N 8 typedef struct list { int data;

    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 #include int fun(char *fname )

    { 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 #include #define N 5 typedef struct { int num; char name[10]; char tel[10]; }STYPE; void check(); /**********found**********/ int fun(___1___ *std) {/**********found**********/ ___2___ *fp; int i; if((fp=fopen(\ return(0); printf(\ for(i=0; i

    第一空:STYPE 第二空:FILE 第三空:fp 89.给定程序的功能是将十进制整数m转换成k进制(2≤k≤9)数的数字输出。例如,如果输入8和2,则应该输出1000。 #include void fun( int m, int k ) { int aa[20], i; for( i = 0; m; i++ ) { /**********found**********/ aa[i] = ___1___; /**********found**********/ m /= ___2___; } for( ; i; i-- ) /**********found**********/ printf( \main() { int b, n; printf( \ scanf( \ fun( n, b );} 第一空:m%k 第二空:k 第三空:aa 90.给定程序的功能是将在字符串s中出现、而未在字符串t中出现的字符形成一个新的字符串放在u中,u中字符按原字符串中字符顺序排列,不去掉重复字符。例如:当s=”112345”,t=”2467”时,u中的字符串为”1135”。 #include #include void fun (char *s,char *t, char *u) { int i, j, sl, tl; sl = strlen(s); tl = strlen(t); for (i=0; i=tl) /************found************/ *u++ = ___2___; } /************found************/ ___3___ = '\\0';} main(){ char s[100], t[100], u[100]; printf(\ scanf(\printf(\ scanf(\ printf(\第一空:break 第二空:s[i] 第三空:*u 91. 给定程序的功能是将大写字母转换为对应的小写字母的第五个字母;若小写字母为v~z,使小写字母的值减去21。转换后的小写字母作为函数值返回。例如,若形参使字母A,则转换为小写字母f;若形参为字母W,则转换为小写字母b。 #include

    #include char fun(char c)

    { 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 float fun ( float r )

    {/**********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 #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 #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 #include #define N 8 typedef struct list { int data;

      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);

      { 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);

      本文来源:https://www.bwwdw.com/article/0fwg.html

Top