填空题已有定义:double*p;,请写出完整的语句,利用malloc函数使p指向一个双精度型的动态存储单元 【4】 。
填空题以下程序中用户由键盘输入一个文件名,然后输入一串字符(用#结束输入)存放到此文件中,形成文本文件,并将字符的个数写到文件的尾部。请填空。
#include<stdio.h>
main()
{ FILE *fp;
char ch,fname[32]; int count=0;
printf(”Input the filename:");
scanf("%s",fname);
if((fp=fopen({{U}} 【12】 {{/U}},"w+"))==NULL)
{ printf("Can't open file:%s/n",fname);exit(0);}
printf("Enter data:/n");
while((ch=getchar())!='#')
{ fputc(ch,fp);count++;}
fprintf({{U}} 【13】 {{/U}},"/n%d/n",count);
fclose(fp);
}
填空题若a=l,b=2,则表达式!(x=a)||y=b)&&0的值是______。
填空题给定程序中,函数fun的功能是:找出N×N矩阵中每列元素中的最大值,并按顺序依次存放于形参b所指的一维数组中。
请在程序的下划线处填入正确的内容,使程序得出正确的结果。
注意:部分源程序给出如下。
不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdio.h>
#define N 4
void fun(int(*a)[N],int*b)
{int i,j;
for(j=0;i<N;i++){
/**********found**********/
b[i]=______;
for(j=1;j<N;j++)
/**********found**********/
if(b[i]______a[j][i])
b[i]=a[j][i];
}
}
main()
{int x[N][N]={{12,5,8,7},{6,1,9,3},{1,2,3,4},{2,8,4,3}},y[N],i,j;
printf("/nThe matrix:/n");
for(i=0;i<N;i++)
{for(j=0;j<N;j++)printf("%4d",x[i][j]);
printf("/n");
}
/**********found**********/
fun(______);
printf("/nThe result is:");
for(i=0;i<N;j++)
printf("%3d",y[i]);
printf("/n");
}
填空题给定程序中,函数fun()的功能是:求输入的两个数中较小的数。 例如:输入5 10,结果为min is 5。 请改正fun()程序中的错误,使它能得出正确的结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。 试题程序、 #include <stdio. h> #include<conio. h> /*************found**************/ int fun(int x, y) int z; z=x<y?x: y; return (z); main ( ) int a,b,c; scanf ("%d, %d/n", c=fun (a, b); printf ("min is %d", c);
填空题下列给定程序中,函数fun()的功能是:将大写字母转换为对应的小写字母之后的第5个字母;若小写字母为v~z,使小写字母的值减21。转换后的小写字母作为函数值返回。例如,若形参是字母A,则转换为小写字母f;形参是字母W,则转换为小写字母b。
请改正函数fun()中的错误,使它能得出正确的结果。
注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构。
试题程序 #include
<stdio.h> #include <ctype.h > char fun(char
c) { if(c>='A' if(c>='a' else if(c>='v' return c; }
main() { char c1, c2; printf("/nEnter a letter
(A-Z):"); c1=getchar();
if(isupper(c1)) { c2=fun(c1); printf("/n/nThe
letter % c change to % c/n" c1, c2); }
else printf "/nEnter (A-Z) ! /n"); }
填空题当先后输入1、3、4、12、23时,屏幕上出现 【11】 ;再输入12时,则屏幕上出现 【12】 。#include <stdio.h>#define N 5main() int i,j,number,top,bott,min,loca,a[N],flag; char c; printf("Please input 5 numbers (a[i]>a[i-1])/n"); scanf("%d",&a[0]); i=1; while (i<N) scanf("%d",&a[i]); if (a[i]>=a[i-1)) i++; printf("/n"); for (i=0;i<N;i++) printf("%d",a[i]); printf("/n"); flag=1; while (flag) scanf("%d",&number); loca=0; top=0; bott=N-1; if ((number<a[0])||(number>a[N-1])) loca=-1; while ((loca==0) && (top<=bott)) min=(bott+top)/2; if (number==a[min]) loca=min; printf("%d is the %dth number/n",number,loca+1); else if (number<a[min]) bott=min-1; else top=min+1; if (loca==0||loca==-1) printf("%d is not in the list./n",number); c=getchar(); if (c=='N'||c=='n') flag=0;
填空题以下程序的输出结果是______。
#include<stdio.h>
int fun2(int a, int b)
{ int c;
c=(a*b)%3; return c;
int fun1(int a, int b)
{ int c;
a+=a; b+=b; c=fun2(a, b);
return c*c;
}
main()
{ int x=11, y=19;
printf("%d/n", fun1(x, y));
}
填空题有以下程序: main() int n=0,m=1,x=2; if(!n)x-=1; if(m)x-=2; if(x)x-=3; printf("%d/n",x); 执行后输出的结果是 [10] 。
填空题以下程序的功能是:借助指针变量找出数组元素中最大值所在的位置并输出该最大值。请在输出语句处填写代表最大值的输出项。
#include<stdio.h>
main()
{int a[10],*P,*s;
for(p=a;p-a<10;p++)scanf("%d",p);
for(p=a,s=a;p-a<10;p++)if(*p>*s) s=p;
printf("max=%d/n",{{U}} (14) {{/U}};
}
填空题以下程序运行后的输出结果是______。 #inClude <strinq.h> char *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);
填空题函数void fun(float*sn,int n)的功能是:根据以下公式计算S,计算结果通过形参指针sn传回;n通过形参传入,n的值大于等于0。请补全程序。 S=1-1/3+1/5-1/7+…+1/(2n+1) void fun(float*sn,int n) float s=0.0,w,f=-1.0; int i=0; for(i=0;i<=n;i++) f= 【14】 *f; w=f/(2*i+1); s+=w; 【15】 =s;
填空题设文件test. txt中原已写入字符串Begin,执行以下程序后,文件中的内容为______。
#include main() { FILE
*fp; fp=fopen("test.txt","w+");
fputs("test",fp);
fcloset(p); }
填空题以下程序运行后的输出结果是{{U}} 【9】 {{/U}}。
main()
{
int p=30;
printf("%d/n",(p/3>0?p/10:p%3));
}
填空题以下程序的输出结果是12.00,请将空白处填写完整。 main() int a=9,b=2; float x= 【18】 ,y=1.1,z; z=a/2+b*x/y+1*2; printf("%52f/n",z);
填空题给定程序中,函数fun的功能是:将自然数1~10以及它们的平方根写到名为myfile3.txt的文本文件中,然后再顺序读出显示在屏幕上。
请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。
不得增行或删行,也不得更改程序的结构!
给定源程序:
#include<math.h>
#include<stdio.h>
intfun(char*fname)
{FILE*fp;int i,n;float x;
if((fp=fopen fname,”w"))==NULL)return ();
for(i=1;i<=10;i++)
/**********found**********/
fprintf(______,"%d %f/n",i,sqrt((double)i));
printf("/nSucceed!!/n");
/**********found**********/
______;
printf("/nThe data in file:/n");
/**********found**********/
if((fp=fopen(______,"r"))==NULL)
return 0:
fscanf(fp,"%d%f",
while(!feof(fp))
{printf("%d%f/n",n,x);
fscanf(fp,"%d%f",}
fclose(fp);
return 1;
}
main()
{char fname[]="myfile3.txt";
fun(fname);
}
填空题以下程序的功能是计算:s=1+12+123+1234+12345。请填空。main() int t=0,s=0,i; for( i=1; i<=5; i++) t=i+ ______; s=s+t; printf("s=%d\n",s);
填空题对有14个结点的完全二叉树的结点以从上到下、从左到右的顺序进行编号后,序号最小的叶结点的序号 【1】 。
填空题以下程序的功能是:输出100以内(不含100)能被3整除且个位数为6的所有整数,请填空。
main()
(int i,j;
for(i=0;【 】;i++)
{j=i*10+6;
if(【 】)continue;
printf("%d",j);
}
}
填空题设有如下宏定义: #define MYSW AP(z,x,y) z=x;x=y;y=z; 以下程序段通过宏调用实现变量a,b内容交换,请填空。 float a=5,b=16,c; MYSWAP( 【20】 ,a,b);
