填空题以下程序的输出结果是 【14】 。 void reverse(int a[],int n) int i,t; for(i=0;i<n/2;i++) t=a[i];a[i]=a[n-1-i];a[n-1-i]=t; main() int b[10]=1,2,3,4,5,6,7,8,9,10;int i,s=0; reverse(b,8); for(i=6;i<10;i++)s+=b[i]; printf("%d/n",s);
填空题以下程序的输出结果是______。 #include<stdio.h> int fun(int x, int y) static int m=0, i=2; i=i+1; m+=i+x+y; return m main() int j=4, m=1, k; k=fun(j, m);printf("gd," , k); k=fun(j, m); printf("%d/n", k)
填空题函数voidfun(float*sn,intn)的功能是:根据以下公式计算S,计算结果通过形参指针sn传回;n通过形参传入,n的值大于等于0。请填空。voidfun(float*sn,intn)floats=0.0,w,f=-1.0;inti=0;for(i=0;i《=n;i++)f=(11)*f;w=f/(2*i+1);s+=w;(12)=s;
填空题给定的程序中,fun函数的功能是:将M行N列的矩阵中的数据,按行的顺序依次放在一维数组中,一维数组中的元素的个数存放在形参n所指的存储单元中。
请在程序的下划线处填写正确的内容,使程序得到正确的结果。
void fun(int(*S)[10],int*b,int*n,int mm,int nn)
{
int i,j;
for(i=0;i<mm;s++,i++)
for(j=0;j<{{U}} (1) {{/U}};j++)
{{U}} (2) {{/U}};
{{U}}(3) {{/U}}
}
main()
{ int w[10][10]={{11,12,13,14},{21,22,23,24},{31,32,33,34}},i,j;
int a[100]={0},n=0:
printf("The matrix:/n");
for(i=0;i<3;i++)
{ for(j=0;j<4;j++) printf("%3d",w[i][j]);
printf("/n");
}
fun(w,a,/n");
for(i=0;i<n;i++)
printf("%3d”,a[i];printf("/n/n");
NONO();严本函数与考生答题无关,考生不得改动,否则后果自负。*/
}
填空题已知字符A的ACSII码值为65,以下语句的输出结果是{{U}} 【6】{{/U}}。
char ch=’B’; printf(“%c %d/n”,ch,ch);
填空题联合变量有以下三个主要用途:(1)节省内存空间;(2)在数据处理问题中,可以用一个数据域存放不同类型的对象;
____
______。
填空题下列程序的功能是计算1~100的整数的累加和。 main() int i, sum= 【13】 ; i=1; for( 【14】 ) sum+=i; i++; printf("sum=%d/n", 【15】 );
填空题以下程序的定义语句中,x[1]的初值是 (7) ,程序运行后输出的内容是 (8) 。 #include<stdio.h> main() int x[]=1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, *p[4], 1; for(i=0; i<4; i++) p[i]=&x[2*i+1]; printf("%d", p[i][0]); printf("/n");
填空题有以下程序: main() int n=0,m=1,x=2; if(!n) x-=1; if(m) x-=2; if(x) x-=3; printf("%d/n",x); 执行后输出的结果是 【9】 。
填空题下列程序的运行结果是{{U}} 【16】 {{/U}}。
#include <string.h>
char *ss(char *s)
{ return s+strlen(s)/2; }
main()
{ char *p,*str="abcdefgh";
p=ss(str); printf("%/n",p);
}
填空题从键盘输入一组小写字母,保存在字符数组str中。请补充函数fun(),该函数的功能是:把字符数组str中字符下标为奇数的小写字母转换成对应的大写字母,结果仍保存在原数组中。
例如,输入“acegikm”,输出“aCeGiKm”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。
试题程序:
#include <stdio.h>
#define N 80
void fun (char s[])
{
int i=0;
while ({{U}} 【1】 {{/U}})
{
if (i%2!=0)
s[i]-={{U}} 【2】 {{/U}};
{{U}} 【3】 {{/U}};
}
}
main ()
{
char str [N];
clrscr ();
printf("/n Input a string:/n");
gets (str);
printf("/n*** original string ***/n");
puts (str);
fun (str);
printf ("In*** new string ***/n");
puts (str);
}
填空题下列给定程序中函数fun()的功能是:实现两个变量值的交换,规定不允许增加语句和表达式。
例如,变量a中的值原为8,b中的值原为3,程序运行后a中的值为3,b中的值为8。
请改正程序中的错误,使它得出正确的结果。
注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构。
试题程序 #include
<stdlib.h> #include <conio.h> #include
<stdio.h> int fun(int*x, int y) { int
t; /* * * * *found* * * * * / t=x;
x=y; /* * * * *found* * * * * / return
(y); } void main() { int a=3,
b=8; printf("% d % d/n", a, b); b=fun( printf("% d % d/n", a, b); }
填空题下面程序的运行结果是______。
#include<stdio.h>
main()
{ int i,f[10];
f[0]=f[1]=1;
for(i=2;i<10;i++)
f[i]=f[i-2]+f[i-1];
for(i=0;i<10;i++)
{if(i%4==0)printf("/n");
printf("%3d",f[i]);
}
}
填空题“printf("%d/n",strlen("/t/"/023/xAB/nC"));”语句的输出结果是______。
填空题下列给定程序中函数fun()的功能是:把从主函数中输入的3个数,最大的数放在a中,中间的数放在b中,最小的数放在c中。
例如,若输入的数为:55,12,34,输出的结果应当是:a=55.0,b=34.0,c=12.0。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdio.h>
void fun(float*a,float*b,float*c)
{
//****found****
float*k;
if(*a<*b)
{
k=*a;
*a=*b;
*b=k;
}
//****ound****
if(*a>*c)
{
k=*c;
*c=*a;
*a=k;
}
if(*b<*c)
{
k=*b;
*b=*c;
*c=k;
}
}
void main()
{
float a,b,c;
printf("Input a b c:");
scanf("%f%f%f",
printf("a=%4.1f,b=%4.1f,c=%4.1f/n/n",a,b,c);
fun(
printf("a=%4.1f,b=%4.1f,c=%4.1f/n/n"a,b,c);
}
填空题下列程序的运行结果为 【4】 。 #include <stdio.h> main() static char str1[40]; char str2140]; strcpy(str2,"China"); strcat(str1,str2); strcat(str1," is a great country !"); printf("%s %s ",str2,strl); printf("%d %d/n",strlen(str2),strlen(str1));
填空题以下程序中函数f的功能是在数组x的n个数(假定n个数互不相同)中找出最大最小数,将其中最小的数与第一个数对换,把最大的数与最后一个数对换。请填空。
# include <stdio.h>
void f(int x[], int n)
{ int p0, p1, i,j,t,m;
i=j=x[O]; p0=p1=O;
for(m=0;m<n;m++)
{ if( x[m]>i ) { i=x[m]; p0=m; }
else if(x[m]<j) {j=x[m]; p1=m;}
}
t=x[p0]; x[p0]=x[n-1]; x[n-1]=t;
t=x[p1]; x[p1]={{U}} 【14】 {{/U}};{{U}} 【15】 {{/U}}=t;
}
main()
{ int a[10], u;
for(u=O;u<10;u++) scanf("%d",
f(a, 10);
for(u=O;u<10;u++) printf(" %d", a[u]);
printf("/n");
}
填空题下面的程序可对指定字符串中的字符串进行从大到小排序,请将程序完整。 (注:程序采用了冒泡排序算法) #include<stdio.h> #include<string.h> main() char*str="ABCDabcd",temp; int n,i; n=strlen(str); while(n->1) for(i=0;i<n;i++) if(str[i]<str[i+1]) temp= 【17】 ; str[i]=str[i+1]; 【18】 =temp; printf( 【19】 );
填空题在对文件进行操作的过程中,若要求文件的位置回到文件的开头,应当调用的函数是{{U}} 【17】 {{/U}}函数。
填空题以下程序的输出结果是______。 void fun( ) static int a=0; a+=2;printf("%d",a); main( ) int cc; for(cc=1;cc<4;cc++)fun( ); printf("/n");
