填空题长度为n的顺序存储线性表中,当在任何位置上插入一个元素概率都相等时,插入一个元素所需移动的元素的平均个数为______。
填空题以下程序运行后的输出结果是{{U}} 【13】 {{/U}}。
# include <string. h>
cbar *ss(char *s)
{ char *p, t;
p=s+1; t=*s;
while(-p){*(p-1)=*p; p++;}
*(p-1)=t;
return s;
}
main()
{ char *p, str[10]="abcdefgh";
p=ss(str);
printf("% s/n", p);
}
填空题在面向对象的程序设计中,类描述的是具有相似性质的=组______。
填空题下列程序的输出结果是 【11】 。 int t(int x,int y,int cp,int dp) cp=x* x+y*y; dp=x*x-y*y; main() int a=4,b=3,c=5,d=6; t(a,b,c,d); printf("%d%d/n",c,d);
填空题下面程序的运行结果是:{{U}} [10] {{/U}}。
fun(int t[],int n)
{ int i,m;
if(n=1) return t[0];
else
if(n>=2) {m=fun(t,n-1);return m;}
}
main()
{ int a[]={11,4,6,3,8,2,3,5,9,2};
printf("%d/n",fun(a,10));
}
填空题以下程序的功能是:删去一维数组中所有相同的数,使之只剩一个。数组中的数已按由小到大的顺序排列,函数返回删除后数组中数据的个数。 例如,若一维数组中的数据是: 2 2 2 3 4 4 5 6 6 6 6 7 7 8 9 9 10 10 10 删除后,数组中的内容应该是: 2 3 4 5 6 7 8 9 10。 请填空。 #include <stdio.h> #define N 80 int fun (int a[], int n) int i,j=1; for(i=1; i<n; i++) if(a[j-1] (10) a[i]) a[j++]=a[i]; (11) main() (int a[N]=(2, 2, 2, 3, 4, 4, 5, 6, 6, 6, 6, 7, 7, 8, 9, 9, 10, 10, 10], i, n=19; printf("The original data: /n"); for(i=0; i<n; i++)printf("%3d", a[i]); n=fun(a,n); printf("/nThe data after deleted: /n"); fori=0; i<n; i++printf("%3d", a[i]); printf("/n/n");
填空题程序MODI1.C中函数fun和funx的功能是:用二分法求方程2x
3
-4x
2
+3x-6=0的一个根,并要求绝对误差不超过0.001。
例如,若给m输入-100,给n输入90,则函数求得的一个根值为2.000。
请改正程序中的错误,使程序能输出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
文件MODI1.C内容如下:
#include<stdio.h>
#include<math.h>
double funx(double x){
return(2*x*x*x-4*x*x+3*x-6);}
double fun(double m,double n){
/***********found**********/
int r;
r=(m+n)/2;
/**********found**********/
while(fabs(n-m)<0.001){
if(funx(r)*funx(n)<0) m=r;
else n=r;
r=(m+n)/2;
}
return r;
}
void main
____
{
double m,n,root;
printf("Enter m n:/n");
scanf("%1f%1f",&m,&n);
root=fun(m,n);
printf("root=%6.3f/n",root);
}
填空题算法的执行过程中,所需要的存储空间称为算法的 【1】 。
填空题以下程序运行后的输出结果是______。 int f(int a[],int n) if(n>=1)return f(a,n-1)+a[n-1]; else return 0; main() int aa[5]=1,2,3,4,5),s; s=f(aa,5);printf("%d/n",s);
填空题下列程序的运行结果是______。 #include<stdio.h> main() int a,b,c; a=3;b=4;c=5; if(a>b) if(a>c) printf("%d",a); else printf("%d",b); printf("%d/n",c);
填空题若变量n的值为24,则print函数共输出{{U}} {{U}} {{/U}} {{/U}}行,最后一行有{{U}} {{U}} {{/U}} {{/U}}个数。
void print(int n,int aa[])
{ int i;
for(i=1;i<n;i++)
{ printf("%6d",aa[i]);
if(!(i%5)) printf("/n");
}
printf("/n");
}
填空题以下函数将b字符串连接到a字符串的后面,并返回a中新字符串的长度。 strcen(char aC), char b[]) int num=0,n=0; while(*(a+num)!= 【14】 ) num++; while(b[n])*(a+num)=b[n]; num++; 【15】 ;) return(num);
填空题若有以下程序:
int f(int x,int y)
{ return (y-x)*x;}
main()
{ int a=3,b=4,c=5,d;
d=f(f(3,4),f(3,5));
printf("%d/n",d);
}
执行后的输出结果是{{U}} 【6】 {{U}}。{{/U}}{{/U}}
填空题若有以下程序
main( )
{ int p,a=5;
if(p=a!=0)
printf("%d/n",p);
else
printf("%d/n",p+2);
}
执行后输出结果是【 】。
填空题请补充main函数,该函数的功能是求方程ax2+bx+c=0的两个实数根。方程的系数a、b、c从键盘输入,如果判别式 (disc=b2-4ac)小于0,则要求重新输入a、b、c的值。 例如,当a=1,b=2,c=1时,方程的两个根分别是x1=-1.00, x2=-1.00。 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。 试题程序: #include"math.h" #include <stdio.h> main() { float a,b,C,disc,X1,x2; clrscr(); do { printf("Input a,b,C:"); scanf("%f,%f,%f",&a,&b,ac); disc=b*b-4*a*c; if(disc<0) printf("disc=%f/n Input again! /n",disc); }while({{U}} 【1】 {{/U}}); printf("****+* the result *+*****/n"); x1={{U}} 【2】 {{/U}}; x2={{U}} 【3】 {{/U}}; printf("/nx1=%6.2f/nx2=%6.2f/n",x1/x2); }
填空题语句printf("%f/n",13.0*(1/5));的输出结果为 【10】 。
填空题为了使下面程序能够正确运行,程序的第2行应填写的内容是
__①__
,当输入的数值为66和99时,该程序输出的结果是
__②__
。
#include<stdio.h>
__①__
int main()
{
double x1, x2;
scanf(:%lf, %lf",
printf("%lf/n", max(x2, x1));
return 0;
}
double max(double y1, double y2)
{
return(y1>y2?y1-y2:y2-y1);
}
填空题下面程序的运行结果是______
#indude <stdio.h>
main()
{int Y,a;
y=2, a=1;
while(y--!=-1)
{do{a*=y; a++;} while(y--);}
printf("%d, %d", a, y);}
填空题请补充main函数,该函数的功能是:从键盘输入一个字符串并保存在字符str1中,把字符串str1中下标为偶数的字符保存在字符串str2中并输出。例如,当str1=“cdefghij”,则 str2=“cegi”。 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。 试题程序: #include<stdio.h> #include<conio.h> #define LEN 80 main() char str1[LEN],str2 [LEN]; char *p1=str1,*p2=str2; int i=0,j=0; clrscr(); printf("Enter the string:/n"); scanf( 【1】 ); printf("***the origial string***/n"); while(*(p1+j)) printf(" 【2】 ",*(p1+j)); j++; for(i=0;i<j;i+=2) *p2++=*(str1+i); *p2='/0'; printf("/nThe new string is:%s/n", 【3】 );
填空题下列给定程序中,函数fun()的功能是:实现两个整数的交换。例如给a和b分别输入60和65,输出为:a=65 b=60 请改正程序中的错误,使它能得出正确的结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。 试题程序; #include<stdio.h> #include <conio.h> /*************found**************/ void fun(int a,b) int t; /*************found**************/ t=b;b=a;a=t; main() int a,b; clrscr(); printf("Enter a, b: "); scanf("%d%d", fun( printf("a=%d b=%d/n ", a,b);
