程序填空题(2)

2019-05-24 13:54

void check();

/**********found**********/ int fun(___STYPE___ *std){ /**********found**********/ ___FILE___ *fp; int i;

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

printf(\ for(i=0; i

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

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

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

{2,\

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

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

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

printf(\file and output to screen :\\n\ printf(\ for(i=0; i

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

printf(\

s[i].num,s[i].name,s[i].tel); } fclose(fp);}

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

第二空:*(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] = ___m%k___;

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

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

printf( \aa___[ i-1 ] );} 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

21. 给定程序的功能是用冒泡法对6个字符进行排序 if (t[i] == s[j]) break;

if (j>=sl) #include

{ for (k=0; k

/************found************/ fun ( char *pstr[6])

if (t[i] == u[k]) ___break___ ; { int i, j ;char *p ;

if (k>=ul) for (i = 0 ; i < 5 ; i++ ) {

/************found************/ for (j = i + 1; j < 6; j++) {

u[ul++] = ___t[i]__ ; /**************found**************/

} } if(strcmp(*(pstr+i),___*(pstr+j)___)>0)

/************found************/ { p = *(pstr + i) ;

___u[ul]___='\\0';} /**************found**************/

main(){ char s[100], t[100], u[100]; pstr[i] = ___*(pstr+j)___ ;

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

scanf(\ *(pstr + j) = ___p___ ; }} }}

printf(\main( )

scanf(\{ int i ;

fun(s, t, u); char *pstr[6], str[6][MAXLINE] ;

printf(\ for(i = 0; i < 6 ; i++) pstr[i] = str[i] ;

printf( \6 str(1 str at each line): \\n\) ; 第一空:break 第二空:t[i] 第三空:u[ul]

for(i = 0 ; i < 6 ; i++) 24.给定程序的功能是将在字符串s中出现、而未在字scanf(\符串t中出现的字符形成一个新的字符串放在u中,u fun(pstr) ; 中字符按原字符串中字符顺序排列,不去掉重复字符。 printf(\例如:当s=”112345”,t=”2467”时,u中的字符串

for(i = 0 ; i < 6 ; i++) 为”1135”。 printf(\#include 第一空:*(pstr+j)或pstr[j] #include

6

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]) ___break___ ; if (j>=tl)

/************found************/ *u++ = ___s[i]___; } /************found************/ ___*u___ = '\\0';} main(){

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

printf(\ scanf(\

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

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

c=c-21;

/**************found**************/ return __c__ ;} main(){ char c1,c2;

printf(\ c1=getchar();

if( isupper( c1 ) ) {

/**************found**************/ c2=fun(___cl___);

printf(\letter \\'%c\\' change to \\'%c\\'\\n\c1,c2); }

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

给定程序的功能是计算

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

25.给定程序的功能是将在字符串s中下标为奇数位置float f( double x){

上的字符,紧随其后重复出现一次,放在一个新串t中, if (x == 0.0 || x == 2.0) t中字符按原字符串中字符出现的逆序排列(注意0为偶/************found************/ 数)。例如:当s=”23516”,t=”1133”。 return ___0__; #include else if (x < 0.0) #include return (x -1)/(x-2); void fun (char *s, char *t) else { int i, j, sl; return (x +1)/(x-2);} sl = strlen(s); double fun( int n ) /************found************/ { int i; double s=0.0, y; if(sl%2) sl-=2; ___else___ sl--; /************found************/ /************found************/ for (i= -n; i<=___n___; i++) for (i=sl, j=___0___; i>=0; i-=2) {y=f(1.0*i); s += y;} { t[2*j] = s[i]; /************found************/ /************found************/ return ___s__;} t[2*j +1] = ___s[i]___ ; main ( ){ printf(\ j++; } 第一空: 0 第二空:n 第三空:s t[2*j]='\\0';}

28.给定程序的功能是求二分之一的圆面积,函数通过main(){ char s[100], t[100];

形参得到圆的半径,函数返回二分之一的圆面积。例如 printf(\

输入圆的半径值为:19.527输入为:s=598.950017。 scanf(\

#include fun(s, t);

float fun ( float r ) printf(\

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

return 3.14159 * ___r*r___ /2.0;}

26.给定程序的功能是将大写字母转换对应的小写字母main ( ) 的第五个字母;若小写字母v~z,使小写字母的值减去/**********found**********/ 21。转换后的小写字母作为函数值返回。例如,若形参{ ___float___ x;

使字母A,则转换为小写字母f;若形参为字母W,则转换 printf ( \为小写字母b。 /**********found**********/ #include scanf ( \&x___ ); #include printf (\char fun(char c) 第一空:r*r 第二空:float 第三空:&x { if( c>='A' && c<='Z')

29.给定程序的功能是将既在字符串s中出现、又在字 c=c+32;

符串t中出现的字符形成一个新字符串放在u中,u中字 if(c>='a' && c<='u')

符按原字符串中字符顺序排列,但去掉重复字符。例如:/**************found**************/

当s=”42562”,t=”34”,u中的字符串为:”5”。 c=c+___5___;

#include else if(c>='v'&&c<='z')

7

27.

#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

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

{ for (k=0; k

if (s[i] _1_ u[k]) break; if (k>=ul)

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

u[ul++]=___s[i]___ ; }} /************found************/ ___u[ul]___ = '\\0';}

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

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

printf(\第一空:== 第二空:s[i] 第三空:u[ul] sl = strlen(s); tl = strlen(t); for (i=0; i

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

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

30.给定程序的功能是从字符串

s尾部开始,按逆序把

相邻的两个字符交换位置,并一次把每个字符紧随其后重复出现一次,放在一个新串t中。例如:当s中的字符串为:“12345”时,则t中的字符串应为:“4455223311”。 #include #include

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

/************found************/ sl = ___strlen(s)___;

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]; } /************forund************/ ___t[j]=0___;} main()

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

printf(\/************found************/ scanf(\s__); fun(s, t);

printf(\第一空:strlen(s) 第二空:t[j]=0 第三空: s

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

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

ul = strlen(up);

for (i=0; i

    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]

    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;

    8

    33.给定程序的功能是计算并输入下列级数的前N项之

    和S(N),直到S(N+1)大于q为止,q的值通过形参传入

    234N?1S?N???????例如:若q的值为50.0,

    123N则函数值为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

    写字母的个数。

    #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( \第一空: (*a)++ 第二空:(*b)++ 第三空:upper,lower

    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 第三空:==

    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( \enter a string:\\n\); gets ( s ); printf (\ c = getchar();

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

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

    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( \2 and 10000: \

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

    printf( \k );

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

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

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

    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**************/

    9

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

    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]

    printf(\

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

    41.给定程序的功能是求出1到1000之内能被7或11

    整除但不能同时被7和11整除的所有整数放存数组a中,通过n返回这些数的个数。 #include

    void fun(int *a, int *n)

    39.给定程序的功能是对a数组中n个人员的工资进行{ int i, j = 0 ;

    分段统计,各段的人数存到b数组中;工资为1000元以下 for(i = 1 ; i <= 1000 ; i++) { 的人数存到b[0]中, 工资为1000元到1999元的人数存/**************found**************/ 到b[1]中, 工资为2000元到2999元的人数存到b[2], if(((i % 7 == 0) || (i % 11 == 0)) && i % 77 != 工资为3000元到3999元的人数存到b[3], 工资为40000) a[j++] = ___1___ ; }

    元到4999元的人数存到b[4],工资为5000元以上的人/**************found**************/ 数存到b[5]中。例如,当a数组中的数据为:900、1800、 *n = ___2___ ;} 2700、3800、5900、3300、2400、7500、3800,调用该main() 函数后,b中存放的数据应是:1、1、2、3、0、2 { int aa[1000], n, k ; #include /**************found**************/ void fun(int a[], int b[], int n) fun ( ___3___ ) ; { int i; for ( k = 0 ; k < n ; k++ ) /**************found**************/ if((k + 1) % 10 == 0) printf(\ for (i=0; i<6; i++) b[i] = ___1___; else printf(\ for (i=0; i= 5000) b[5]++;

    42.给定程序中已经建立一个带有头结点的单向链表,/**************found*************/

    在main函数中将多次调用fun函数,每调用一次fun函 ___2___ b[a[i]/1000]++;}

    数,输出链表尾部结点中的数据,并释放该结点,使链表main()

    { int i, a[100]={ 900, 1800, 2700, 3800, 5900, 缩短。

    #include 3300, 2400, 7500, 3800}, b[6];

    #include fun(a, b, 9);

    #define N 8 printf(\

    typedef struct list /**************found**************/

    { int data; for (i=0; i<6; i++)

    struct list *next; printf(\

    } SLIST; printf(\

    void fun( SLIST *p) 第一空:0 第二空:else 第三空:b[i]

    { SLIST *t, *s;

    40.给定程序的功能是将n个人员的考试成绩进行分段 t=p->next; s=p;

    统计,考试成绩放在a数组中,各分数段的人数存到b while(t->next != NULL) 数组中:成绩为60到69的人数存到b[0], 成绩为70 { s=t;

    到79的人数存到b[1], 成绩为80到89的人数存到b[2], /**********found**********/ 成绩为90到99的人数存到b[3],成绩为100的人数存 t=t->___1___; }

    到b[4],成绩为60分以下的人数存到b[5]中。例如,当/**********found**********/ a数组中的数据是:93、85、77、68、59、43、94、75、 printf(\98。调用该函数后,b数组中存放的数据应是:1、2、1、 s->next=NULL; 3、0、2。 /**********found**********/ #include free(___3___);} void fun(int a[], int b[], int n) SLIST *creatlist(int *a) { int i; { SLIST *h,*p,*q; int i; for (i=0; i<6; i++) b[i] = 0; h=p=(SLIST *)malloc(sizeof(SLIST)); /**************found**************/ for(i=0; idata=a[i]; p->next=q; p=q;} /**************found**************/ p->next=0; ___2___ b[(a[i]- 60)/10]++;} return h;} main() void outlist(SLIST *h) { int i, a[100]={ 93, 85, 77, 68, 59, { SLIST *p; 43, 94, 75, 98}, b[6]; p=h->next; /**************found**************/ if (p==NULL) printf(\ fun(___3___, 9); else printf(\ { printf(\ for (i=0; i<6; i++) printf(\ do{printf(\ p=p->next; }

    10


程序填空题(2).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:八年级上册思品复习主要知识点(精品)

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: