填空题请补充 fun 函数, 该函数的功能是: 计算 N N 维矩阵元素的方差
填空题(3)支持Internet基本服务的协议是{{U}} 【3】 {{/U}}。
填空题当执行以下程序时,输入1234567890<回车>,则其中while循环体将执行{{U}} 【7】 {{/U}}次。
#include<stdio.h>
main()
{ char ch;
while((ch=getchar())=='0')prinft("#");
}
填空题请补充函数fun(),该函数的功能是:返回字符数组中指定子符的个数,指定字符从键盘输入。 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。 试题程序: #include <stdio.h> #define N 80 int fun (char s[],char ch) int i=0, n=0; while( 【1】 ) if( 【2】 ) n++; i++; 【3】 ; main ( ) int n; char str[N], ch; clrscr (); printf ("/nInput a string: /n"); gets (str); printf ("/nInput a charactor: /n" ; scanf ("%c", n=fun (str, ch); printf("/nnumber of %c:%d", ch, n);
填空题下列给定程序中,函数fun的功能是:根据形参i的值返回某个函数的值。当调用正确时,程序输出:x1=5000000,x2=3.000000,x1*x1+x1*x2=40.000000
请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。
注意
:部分源程序给出如下。
不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdio.h>
double f1(double x)
{return x*x;}
double f2(double x,double y)
{return x*y;}
/********found********/
______fun(int i,double x,double y)
{if(i==1)
/********found********/
return______(x);
else
/********found********/
return ______(x,y);
}
main()
{double x1=5,x2=3,r;
r=fun(1,x1,x2);
r+=fun(2,x1,x2);
printf("/nx1=%f, x2=%f, x1+x1+x1*x2=%f/n/n", x1, x2, r);
}
填空题下列程序的输出结果是______。
main()
{ int a=2,b=4,c=6;
int*p1=
*(p=
printf("%d/n",c);
}
填空题以下程序运行后的输出结果是{{U}} 【7】 {{/U}}。
#define S(x)4*x*x+1
main()
{ int i=6,j=8;
printf("%d/n",S(i+j));
}
填空题用以下语句调用库函数malloc,使字符指针st指向具有11个字节的动态存储空间。 st=(char*) 【10】 ;
填空题给定程序中,函数fun的功能是:将形参s所指字符串中的所有数字字符顺序前移,其他字符顺序后移,处理后新字符串的首地址作为函数值返回。 例如,s所指字符串为:asdl23fgh5##43df, 处理后新字符串为:123543asdfgh##df。 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在函数fun的行线上填入所编写的若干表达式或语句。 [试题源程序] #include<stdio.h> #include<string.h> #include<stdlib.h> #include<ctype.h> char*fun(Char*s) int i,j,k,n;char *p,*t; n=strlen(s)+1; t=(char*)malloc(n*sizeof(char)); p=(char*)malloc(n*sizeof(char)); j=0;k=0; for(i=0;i<n;i++) if(isdigit(s[i])) /**********found**********/ p[ (1) ]=s[i];j++; else t[k]=s[i];k++; A*********found**********/ for(i=0;i< (2) ;i++)p[j+i]=t[i]; p[j+k]=0; /**********found**********/ return (3) ; main() char s[80]; printf("Please input:");scanf("%s",s); printf("/nThe result is: %s/n",fun(s));
填空题若有定义语句char s[100],d[100];int j=0,i=0;且s中已赋字符串,请填空以实现拷贝。 (注:不使用逗号表达式)
while(s[i])(d[j]={{U}} 【10】 {{/U}};j++;}
d[j]=0;
填空题以下函数用来在w数组中插入x。n所指向的存储单元中存放w数组中字符个数。数组w中的字符已按从小到大的顺序排列,插入后数组w中的字符仍有序。请填空。 void fun(char*w,char x,int*n) int i, p; p=0; w[*n]=x; while(x>w[p])p++; for(i=*n;i>p;i--)w[i]= 【13】 ; w[p]=x; ++ *n;
填空题下列给定程序中,函数fun()的功能是;求S的值。设 S=(22/1*30))*(42/(3*5))*(62/(5*7))*…*(2k)2/((2k-1)*(2k+1)) 例如,当k为10时,函数的值应为1.533852。 请改正程序中的错误,使它能得出正确的结果。 注童;不要改动main 函数,不得增行或删行,也不得更改程序的结构。 试题程序: #include <conio. h> #include <stdio. h> #include <math.h > /**************found***************/ fun (int k) iht n; float s, w, p, q; n=1; s=1.0; while (n<=k) w=2. 0*n; p=w-1.0; q=w+1.0; s=s*w*w/p/q; n++; /***************found**************/ return s main() clrscr (); printf ("%f/n ", fun (10));
填空题以下程序中函数f的功能是在数组x的n个数(假定n个数互不相同)中找出最大最小数,将其中最小的数语第一个数兑换,把最大的数语最后一个数对换。请填空。 #include <stdio.h> void f(int x[ ],int n) int p0,p1,i,j,t,m; i=j=x[0]; p0=p1=0; 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]=______;______=t; main( ) int a[10],u; for(u=0;u<10;u++) scanf("%d", f(a,10); for(u=0;u<10;u++) printf("%d",a[u]); printf("/n");
填空题以下程序的运行结果是 【12】 。 # include<string.h> typedef struct student char name[10]; long sno); float score STU; main() STU a="zhangsan",2001,95,b="Shangxian",2002,90 c="Anhua",2003,95,d,*p= d=a; if(strcmp(a.name,b.name)>0)d=b; if(strcmp(c.name,d.name)>0)d=c; printf("%1d%s/n",d.sno,p->name);
填空题以下程序的功能是:从键盘上输入若干学生的成绩,统计计算出平均成绩,并输出低于平均分的学生成绩,用输入负数结束输入。填空。 main( ) float x[1000],sum,=0.0,ave a; int n=0,i; printf("Enter mark:"\n");scanf("%f",&a); while(a>=0.0 & &n<1000) sum += 【10】 ;x[n]= 【11】 ; n+ +;scanf("%f",& a); ave= 【12】 ; printf("Output:"\n"); printf("ave=%f"\n",ave); for(i=0,i<n;i+ +) if( 【13】 )frintf("%f\n",x[i]);
填空题当线性表的操作无插入和删除时,采用 【3】 结构为好。
填空题下列给定的程序中,函数fun()的功能是:求输入的两个数中较小的数。 例如:输入5
10,结果为min is 5。 [注意] 部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。
[试题源程序] #include
<stdio.h> #include <conio.h> int
fun(int x, {{U}} {{U}} {{/U}} {{/U}};
int z; z=x<y{{U}} {{U}} {{/U}}
{{/U}}x:y; return(z); }
main() int a, b, c; scanf("%d, %d/n",
{{U}} {{U}} {{/U}} {{/U}}); c=fun(a,
b); printf("min is%d:, c); }
填空题若有以下程序
main( )
{ int p,a=5;
if(p=a!=0)
printf("%d/n",p);
else
printf("%d/n",p+2);
}
执行后输出结果是{{U}} 【8】 {{/U}}。
填空题以下程序从终端读入数据到数组中,统计其中正数的个数,并计算它们之和。请填空。
main()
{ int i, a[20], sum, count;
sum=count=0;
for(i=0; i<20; i++)scanf("% d", {{U}}【8】 {{/U}});
for(i=0; i<20; i++)
{ if(a[i]>0)
{ count++;
sum+=a[i];
}
}
printf("sum=% d, count=% d/n", sum, count);
}
填空题给定程序中,函数fun的功能是:计算下式前n项的和作为函数值返回。例如,当形参n的值为10时,函数返回:-0.204491。请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。不得增行或删行,也不得更改程序的结构!给定源程序:#include<stdio.h>doublefun(intn){inti,k;doubles,t;s=0;/**********found**********/k=________;for(i=1;i<=n;i++){/**********found**********/t=________;s=s+k*(2*i-1)*(2*i+1)/(t*t);/**********found**********/k=k*________;}returns;}main(){intn=-1;while(n<0){printf("Pleaseinput(n>0):");scanf("%d",}printf("/nTheresultis:%f/n",fun(n));}
