填空题以下程序运行后的输出结果是______。main() char c1,c2; for(c1='0',c2='9';c1<C2;C1++,C2--) PRINTF("%C%C",C1,C2);printf("/n");
填空题下列程序的运行结果是: {{U}} 【16】 {{/U}}
#include <string.h>
char *ss(char *s)
{ return s+strlen(s)/2;}
main( )
{ char *p,*str=”abcdefgh”;
p=ss(str); printf(“%s/n”,p);}
填空题请补充 fun 函数, 该函数的功能是: 计算 N N 维矩阵元素的方差
填空题下列程序的功能是将2个数从小到大输出。
main()
{ float a,b,{{U}} 【10】 {{/U}};
scanf({{U}} 【11】 {{/U}},&a,&b);
if(a>b)
{ t=a;
{{U}} 【12】 {{/U}};
b=t;
}
printf("%5.2f,%5.2f/n",a,b);
}
填空题设变量已正确定义为整型,则表达式n=i=12,++i,i++的值为______。
填空题用以下语句调用库函数malloc,使字符指针st指向具有11个字节的动态存储空间。 st=(char*) 【10】 ;
填空题已知一个数列从0项开始的前3项:0、0、1,以后的各项都是其相邻的前3项之和。下列给定的程序中,函数fun的功能是:计算并输出该数列前n项的平方根之和sum。n的值通过形参传入。
例如,当n=10时,程序的输出结果应为23.197745。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdlib.h>
#include<conio.h>
#include<stdio.h>
#include<math.h>
/*********found*********/
fun(int n)
{double sum,s0,s1,s2,s;
int k;
sum=1.0;
if(n<=2)sum=0.0;
s0=0.0;s1=0.0;s2=1.0;
for(k=4;k<=n;k++)
{s=s0+s1+s2;
sum+=sqrt(s);
s0=s1;s1=s2;s2=s;
}
/*********found*********/
return sum
}
void main()
{int n;
system("CLS");
printf("Input N=");
scanf("%d",
printf("%f/n",fun(n));
}
填空题(3)支持Internet基本服务的协议是{{U}} 【3】 {{/U}}。
填空题给定程序中函数fun的功能是:先将在字符串s中的字符按正序存放到t串中,然后把s中的字符按逆序连接到t串的后面。
例如:当s中的字符串为:"ABCDE"时,
则t中的字符串应为:"ABCDEEDCBA"。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
给定源程序:
#include<stdio.h>
#include<string.h>
void fun(char*s,char*t)
{int i,sl;
sl=strlen(s);
/**********found**********/
for(i=0;i<=s1;i++)
t[i]=s[i];
for(i=0;i<sl;i++)
t[sl+i]=s[sl-i-1];
/**********found**********/
t[sl]="/0";
}
main()
{char s[100],t[100];
printf("/nPlease enter string s:");scanf("%s",s);
fun(s,t);
printf("The result is:%s/n",t);
}
填空题请补充函数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()将指定源文件中的内容复制到指定的目标文件中,复制成功时函数返回1,失败时返回0。在复制的过程中,把复制的内容输出到屏幕。主函数中源文件名放在变量sfname中,目标文件名放在变量tfname中。
请在标号处填入正确的内容,使程序得出正确的结果。 注意:部分源程序给出如下。
不得增行或删行,也不得更改程序的结构。
试题程序 #include
<stdio.h> #include <stdlib.h> int fun(char
*source, char *target) { FILE *fs, *ft; char ch;
if((fs=fopen(source, ______))==NULL)return 0;
if((ft=fopen(target, "w"))==NULL)return 0; printf("/nThe data
in file:/n"); ch=fgetc(fs);
while(!feof(______)) { putchar(ch); fputc(ch,
______); ch=fgetc(fs); }
fclose(fs); fclose(ft); printf("/n/n"); return
1; } main() { char sfname[20]
="myfile1", tfname[20]="myfile2"; FILE *myf; int i; char
c; myf=fopen(sfname, "w"); printf("/nThe
original data:/n"); for(i=1; i<30; i++) {
c='A'+rand()% 25; fprintf(myf, "% c", c); printf("% c",
c); } fclose(myf); printf("/n/n");
if(fun(sfname, tfname)) printf("Succeed!");
else printf("Fail!"); }
填空题当执行以下程序时,输入1234567890<回车>,则其中while循环体将执行{{U}} 【7】 {{/U}}次。
#include<stdio.h>
main()
{ char ch;
while((ch=getchar())=='0')prinft("#");
}
填空题给定程序中,函数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));
填空题下列程序的输出结果是______。
main()
{ int a=2,b=4,c=6;
int*p1=
*(p=
printf("%d/n",c);
}
填空题下列给定程序中,函数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);
}
填空题以下程序运行后的输出结果是{{U}} 【7】 {{/U}}。
#define S(x)4*x*x+1
main()
{ int i=6,j=8;
printf("%d/n",S(i+j));
}
填空题若有定义语句char s[100],d[100];int j=0,i=0;且s中已赋字符串,请填空以实现拷贝。 (注:不使用逗号表达式)
while(s[i])(d[j]={{U}} 【10】 {{/U}};j++;}
d[j]=0;
填空题下列给定程序中,函数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));
填空题以下函数用来在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;
填空题以下程序中函数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");
