填空题调用C语言标准库函数时要求用{{U}} 【9】 {{/U}}命令。
填空题一张3.5英寸软盘大约能存储140万个ASCⅡ字符,若存放汉字大约能存放 【1】 个。
填空题给定程序中,函数fun的功能是:统计出带有头结点的单向链表中结点的个数,存放在形参n所指的存储单元中。
请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。
#include<stdio.b>
#include<stdlib.h>
#define N 8
typedef struct list
{int data;
struct list*next;}SLIST;
SLIST*creatlist(int*a);
void outlist(SLIST*);
void fun(SLIST*h,int*n)
{SLIST*p;
/**********found**********/
______=0;
p=h->next;
while(p)
{(*n)++;
/**********found**********/
p=p->______;
}
}
main()
{SLIST*head;
int a[N]={12,87,45,32,91,16,20,48},num;
head=creatlist(a);outlist(head);
/**********found**********/
fun(______,
printf("/nnumber=%d/n",num);
}
SLIST*creatlist(int a[])
{SLIST*h,*p,*q;int i;
h=p=(SLIST*)malloc(sizeof(SLIST));
for(i=0;i<N;i++)
{q=(SLIST*)malloc(sizeof(SLIST));
q->data=a[i];p->next=q;p=q;
}
p->next=0;
return h;
}
void outlist(SLIST*h)
{SLIST*p;
p=h->next;
if(p==NULL)printf("The list is NULL!/n");
else
{printf("/nHead");
do
{printf("->%d",P->data);p=p->next;}
while(p!=NULL);
printf("->End/n");
}
}
填空题以下程序由终端键盘输入一个文件名,然后把从终端键盘输入的字符依次存放到该文件中,用#作为结束输入的标志,请填空。 #include<stdio.h> main() FILE *fp; char ch,fname[10]; printf("Input the nam /n"); gets(fname); if((fp= 【17】 ==NULL) printf("Cannot open/n"); exit(0); printf("Enter data/n"); while(ch=getchar()!='#') fputc( 【18】 ,fp); fclose(fp);
填空题下列程序执行后输出的结果是 【11】 。 main() int arr[10],i,k=0; for(i=O;i<10;i++)arr[i]=i; for(i=1;i<4;i++)k+=arr[i]+i; printf("%d/n",k);
填空题下列给定程序中,函数fun()的功能是:对N名学生的学习成绩,按从高到低的顺序找出前m(m≤10)名学生来,并将这些学生数据存放在一个动态分配的连续存储区中,此存储区的首地址作为函数值返回。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<malloc.h>
#include<string.h>
# include<conio.h>
#define N 10
typedef struct ss
{
char num[10];
int order;
}STU;
STU *fun(STU a[], iht m)
{
STU b[N], *tt;
int i,j,k;
{{U}}【1】 {{/U}};
for(i=0; i<N; i++)
b[i]=a[i];
for (k=0;k<m;k++)
{
for (i=j=0;i<N;i++)
if ({{U}} 【2】 {{/U}})
j=i;
tt [k]=b[j];
b[j].order=0;
}
return{{U}} 【3】 {{/U}};
}
outresult (STU a[],FILE *pr)
{
int i;
for(i=0;i<N; i++)
fprintf(pf,"No=%s Mark=%d/n",
a[i].num,a[i].order);
fprintf(pf,"/n/n");
}
main()
{
STU [N]={{"A01",80},{"A02",79},
{"A03",66},{"A04",82},{"A05",87},
{"A06",93},{"A07",78},{"A08",60},
{"A09",85},{"A10",73}};
STU *p_order;
int i,m;
clrscr();
printf("*** The Origial data ***/n");
outresult(a, stdout);
printf("/nGive the numeber of the
students who have better score:");
scanf("%d",
while (m>10)
{
printf("/nGive the number of the
studets who have better score:");
scanf("%d",
}
p_order=fun(a,m);
printf("*** THE RESULT ***/n");
printf("*** The top students ***/n");
for(i=0; i<m; i++)
printf (" %s %d/n",
p_order[i].num,p_order[i].order);
free(p_order);
}
填空题下列程序执行后输出的结果是 【9】 。 main() int arr[10],i,k=0); fot(i=0;i<10;i++)art[i]=i; for(i=1:i<4;i++) k+=arr[i]+i; printf("%d/n",k);
填空题设文件test. txt中原已写入字符串Begin,执行以下程序后,文件中的内容为______。 #include main() FILE *fp; fp=fopen("test.txt","w+"); fputs("test",fp); fcloset(p);
填空题下列程序的输出结果是______。
#include<stdio.h>
main()
{ intx=3,y=2,z=1;
if(x<y)
if(y<0)z=0;
else z+=1;
printf("%d/n",z);
}
填空题下面的语句要使指针p指向一个double类型的动态存储单元,请填空。 p = 【13】 malloc(sizeof(double));
填空题以下程序的功能是:求出数组x中各相邻两个元素的和,依次存放到a数组中,然后输出,请填空。 main() int x[10],a[9],I; for(i=0;i<10;i++) scanf("%d",&x[i]); for(i=1;i<10;i++) a[i-1]=x[i]+______; for(i=0;i<9;i++) printf("%d",a[i]); printf("/n");
填空题以下程序从终端输入一行字符放在s数组中,输入以回车符作为结束,函数fun统计存放在s数组中每个数字字符的个数。形参ch指向s数组,形参n给出了s数组中字符的个数。在acc数组中用下标为0的元素统计字符“0”的个数,下标为1的元素统计字符“1”的个数,…。请填空。
#include <stdio.h>
void fun(int *,char*,int);
main()
{ char s[80],c; int acc[10],i=0;
printf("Enter characters:/n");
while((c=getchar())!='/n')s[{{U}} 【11】 {{/U}}]=c;
fun({{U}} 【12】 {{/U}});
for(i=0;i<10;i++)printf("%c:%d/n",'0'+i,acc[i]);
printf("/n/n");
}
void fun(int *a,char *ch,int n)
{ int i,d;
for(i=0;i<10;i++)a[i]={{U}} 【13】 {{/U}};
for(i=0;i<n;i++)
{ d={{U}} 【14】 {{/U}}; a[d]++; }
}
填空题软件测试按功能划分的方法划分,通常分为 【3】 测试方法和黑盒测试方法。
填空题以下程序中,函数fun的功能是计算x2(上标)-2x+6,主函数中将调用fun函数计算:
y1=(x+8)2(上标)-2(x+8)+6
y2=sin2(上标)(x)-2sin(x)+6
请填空。
#include "math.h"
double fun(double x){ return (x*x-2*x+6);}
main()
{ double x,y1,y2;
printf("Enter x:"); scanf("%1f",
y1=fim({{U}} [11] {{/U}});
y2=run({{U}} [12] {{/U}});
printf("y1=%1f,y2=%1f/n",y1,y2);
}
填空题以下程序的运行结果是 【9】 。 #include <stdio.h> main() int x=1,y=0,a=0,b=0; switch(x) case 1: switch(y) case 0:a++; break; case 1: b++; break; case 2:a++; b++;break; case 3:a++;b++; printf("a=%d,b=%d/n",a,b);
填空题以下程序的功能是从键盘输入若干学生的成绩,并输出最高成绩和最低成绩,当输入负数时结束。请填空。 #include <stdio.h> main() float x,amax,amin; scanf("%f",&x); amax=x; amin=x; while( 【7】 ) if(x>amax)amax=x; else if( 【8】 ) amin=x; scanf("%f",&x); printf("/n amax=%f/n amin=%f/n",amax,amin);
填空题下列给定程序中,函数fun的功能是:把形参s所指字符串中最右边的n个字符复制到形参t所指字符数组中,形成一个新串。若s所指字符串的长度小于n,则将整个字符串复制到形参t所指字符数组中。
例如,形参s所指的字符串为:abcdefgh,n的值为5,程序执行后t所指字符数组中的字符串应为:defgh。
请在程序的下划线处填入正确的内容,使程序得出正确的结果。
注意:部分源程序给出如下。
不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdio.h>
#include<string.h>
#define N 80
void fun(char*s,int n,char*t)
{int len,i,j=0;
len=strlen(s);
/********found********/
if(n>len)strcpy(______);
else{
/********found********/
for(i=len-n;i<=len-1;i++)
t[j++]=______;
/********found********/
t[j]=______;
}
}
main()
{char s[N],t[N];int n;
printf("Enter a string:");
gets(s);
printf("Enter n:");
scanf("%d",&n);
fun(s,n,t);
printf("The string t:");puts(t);
}
填空题请补充fun()函数,fun函数的功能是求m的阶乘。
请勿改动main()函数与其他函数中的任何内容,仅在fun()函数的横线上填写所需的若干表达式语句。
注意:部分源程序给出如下。
试题程序:
#include<stdio.h>
long fun(int m)
{
if(______)
return(m*fun(______));
return ______;
}
void main()
{
printf("8!=%ld/n",fun(8));
}
填空题给定程序MODI1.C中函数fun的功能是:求出s所指字符串中最后一次出现的t所指字符串的地址,通过函数值返回,在主函数中输出从此地址开始的字符串。若未找到,则函数的返回值为NULL。例如,字符串s中的内容为“abcdabfabcdx”,若t中的内容为“ah”时,则输出结果为:abcdx;若t中的内容为“abd”,则程序输出未找到的信息:not be found!。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
文件MODI1.C内容如下:
#include<stdio.h>
#include<string.h>
char *fun(char *s,char *t){
char *p,*r,*a;
/**********found**********/
a=NUll;
while(*s){
p=s;r=t;
while(*r)
/**********found**********/
if(r==P){r++;p++;}
else break;
if(*r=="/0")a=s;
s++:
}
return a;
}
void main
____
{
char s[100],t[100],*p;
printf("/nPlease enter string s: ");
scanf("%s",s);
printf("/nPlease enter string t: ");
scanf("%s",t);
p=fun(s,t);
if(P)printf("/nTbe result is: %s/n",p);
else printf("/nNot found!/n");
}
填空题以下程序运行后的输出结果是{{U}} 【14】 {{/U}}。
main()
{char s[]="9876",*p;
for(p=s;p<s+2;p++)printf("%s/n",p);
}
