填空题给定程序中,函数fun的功能是:判断形参s所指字符串是否是”回文”(Palindrome),若是,函数返回值为1;不是,函数返回值为0。”回文”是正读和反读都一样的字符串(不区分大小写字母)。
例如,LEVEL和Level是”回文”,而LEVLEV不是”回文”。
请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。
注意:源程序存放在
下的BLANK1. C中。不得增行或删行,也不得更改程序的结构!
#include <stdio, h>
#include <string. h>
#include <ctype. h>
int fun(char *s)
{char *lp, *rp;
/**********found**********/
lp=______;
rp=s+strlen(s)-1;
while((toupper(*lp)==toupper
(*rp)) rp ______;}
/**********found***********/
if(lp<rp) ______;
else return 1;
}
main( )
{ char s[81];
printf("Enter a string:"); scanf
("%s", s);
if(fun(s)) printf("/n"%s" is a
Palndrome./n/n", s);
else printf("/n"96s" isn"t a
Palindrome./n/n", 8);
}
填空题在DOS环境下,表示打印机的设备文件名是{{U}} 【5】 {{/U}}。
填空题下列给定程序中,函数fun()的功能是:对Ⅳ名学生的学习成绩,按从高到低的顺序找出前m(m≤10)名学生来,并
将这些学生数据存放在一个动态分配的连续存储区中,此存储区的首地址作为函数值返回。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构。 试题程序
#include <stdlib.h> #include <conio.h>
#include <string.h> #include <stdio.h>
#include <malloc.h> #define N 10 typedef
struct ss { char num[10]; int s;
} STU; STU *fun(STU a[], int m) { STU
b[N], *t; int i, j, k; /* * * * *found* * * *
* / *t=calloc(m, sizeof(STU)); for(i=0; i<N;
i++) b[i]=a[i]; for(k=0; k<m; k++)
{ for(i=j=0; i<N; i++) if(b[i].s>b[j].s)
j=i; /* * * * *found* * * * * /
t[k]=num=b[j].num; t[k].s=b[j].s;
b[j].s=0; } return t;
} outresult(STU a[], FILE *pf) { int
i; for(i=0; i<N; i++) fprintf(pf, "No=% s
Mark=% d/n", a[i].num, a[i].s); fprintf(pf, "/n/n");
} void main() { STU a[N]={{"A01", 81},
{"A02", 89}, {"A03", 66}, {"A04", 87}, {"A05", 77},
{"A06", 90}, {"A07", 79}, {"A08", 61}, {"A09", 80},
{"A10", 71}}; STU *pOrder; int i, m;
printf("* * * *THE RESULT* * * * /n"); outresult(a,
stdout); printf("/nGive the number of the students who have
better score:"); scanf("% d",
while(m>10) { printf("/ nGive the number of the students who
have better score:"); scanf("% d",
} pOrder=fun(a, m); printf("* * * *THE RESULT*
* * *n") ; printf("The top:/n"); for(i=0; i printf("% s % d/n", pOrder[i].num, pOrder[i].s);
free(pOrder); }
填空题请在以下程序第一行的下划线处填写适当内容,使程序能正确运行。 【16】 (double,double); main() double x,y; scanf("%1f%1f", printf("%1f/n",max(x,y)); double max(double a,double b) return(a>b ? a:b);
填空题以下程序用来输出结构体变量student所占存储单元的字节数,请填空。 struct st char name[20];double score; ; main() struct st student; printf("student size:%d/n",sizeof(______));
填空题调用C语标准库函数时要求用______命令。
填空题给定程序中,函数fun的功能是:计算x所指数组中N个数的平均值(规定所有数均为正数),平均值通过形参返回给主函数,将小于平均值且最接近平均值的数作为函数值返回,并在主函数中输出。
例如,有10个正数:46、30、32、40、6、17、45、15、48、26,平均值为30.500000。
主函数中输出m=30。
请在程序的下画线处填入正确的内容并把下画线删除,使程序得出正确的结果。
注意:不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdlib.h>
#include<stdio.h>
#define N 10
double fun(double x[],double*av)
{int i,j;double d,s;
s=0;
for(i=0; i<N; i++)s=s+x[i];
/*********found*********/
______=s/N;
d=32767;
for(i=0;i<N;i++)
if(x[i]<*av
j=______;
}
/*********found*********/
return ______;
}
main()
{int i; double x[N],av,m;
for(i=0; i<N; i++)
{ x[i]=rand()%50;
printf("%4.0f",x[i]);)
printf("/n");
m=fun(x,
printf("/nThe average is:%f/n",av);
printf("m=%5.1f",m);
printf("/n");
}
填空题函数pi的功能是根据以下近似公式求π值: (π*π)/6=1+1/(2*2)+1/(3*3)+...+1(n*n) 现在请你在下面的函数中填空,完成求π的功能。 #include "math.h" double s=0.0; long i; for(i=1;i<=n;i++)s=s+ 【7】 ; return(sqrt(6*S));
填空题下面程序的功能是输出数组中最大的数,由a指针指向该元素。请填空。 main() int s[]=6,7,2,13,9,1,12,10,5,8,4,3,11),*a,*b; for( 【7】 ) if(*a<*b) a=b; printf("%d",*a);
填空题45. 以下程序中,函数SumColumMin的功能是:求出M行N列二维数组每列元素中的最小值,并计算它们的和值,和值通过形参传回主函数输出。请填空, #include <stdio.h> #define M 2 #define N 4 void SumColumMin ( int a [M] [N] ,int* sum) int i,j,k,s=0; for(i =0;i<N;i ++ ) k=O; for(j=1 ;j < M;j ++ ) if(a[k][i] >a[j][i]) k=j; s+:{{U}} {{/U}}; {{U}} {{/U}}=s; main( ) int x[M] [N]=3,2,5,1,4,1,8,3,s; SumColumMin({{U}} {{/U}}); printf( "%d //n" ,s);
填空题在E-R图中.图形包括矩形框、菱形框、椭网框。其中表示实体联系的是______框。
填空题若有定义语句char s[100],d[100];int j=0,i==0;且s中已赋字符串,请填空以实现拷贝。 (注:不使用逗号表达式)
while(s[i]={{U}} 【15】 {{/U}};j++;}
d[j]=0;
填空题以下程序的输出结果是 (9) 。 main() int a[3][3]=1,2,9,3,4,8,5,6,7,i,s=0; for(i=0;i<3:i++)s+=a[i][i]+a[i][3-i-1]; printtf(“%d/n”,s);
填空题以下程序段的输出结果是 【9】 。 main() int a=2,b=3,c=4; a*=16+(b++)-(++c); printf("%d",a);
填空题设有以下定义stnctssintinfo;sEruc5ss*link;x.y,z;且已建立如下图所示链表结构:请写出删除结点y的赋值语句______。
填空题下面程序的功能是将字符串a下标值为偶数的元素由小到大排序,其他元素不变,请填空。
#include<stdio.h>
main()
{char a[]="labchmfye",t;
int i,j;
for(i=0;i<7;i+=2)
for(j=i+2;j<9;{{U}} 【15】 {{/U}})
if({{U}} 【16】 {{/U}})
{t=a[i]; a[i]=a[j]; a[j]=t;j++;}
puts(a);
printf("/n");
}
填空题给定程序中,函数fun的功能是:计算出形参s所指字符串中包含的单词个数,作为函数值返回。为便于统计,规定各单词之间用空格隔开,字符串中只有字母与空格。
例如,形参s所指的字符串为:This is a C language program,函数的返回值为6。
请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。
不得增行或删行,也不得更改程序的结构!
给定源程序:
#include <stdio.h>
int fun(char*s)
{int n=0,flag=0;
while(*s!="/0")
{if(*s!="" flag=1;}
/**********found**********/
if(*s=="")flag=______;
/**********found**********/
______;
}
return n;
}
main()
{char str[81]; int n;
printf("/nEnter a line text:/n"); gets(str);
n=fun(str);
printf("/nThere are %d words in this text./n/n",n);
}
填空题下面程序的运行结果是 【18】 。 void swap(int *a,int *b) int *tp; t=a;a=b;b=t; main() int x=3,y=5,*p= swap(p,q); printf("%d%d/n",*p,*q);
填空题以下程序的输出结果是_______。
main()
{char*p[]={"BOOL","OPK","H","SP:,};
for(i=3;i>0;i--,i--)printf("%c",*p[i]);
printf("/n");}
填空题以下程序运行后的输出结果是 {{U}}【12】{{/U}} 。
main()
{ char a[]="123456789",*p; int i=0;
p=a;
while(*p)
{ if(i%2==0)*p='*';
p++;i++;
}
puts(a);
}