填空题给定程序中,函数fun()的功能是在带有头结点的单向链表中,查找数据域中值为ch的结点。找到后通过函数值返回该结点在链表中所处的顺序号;若不存在值为ch的结点,函数返回0值。 请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。 #include<stdio.h> #include<stdlib.h> #define N 8 typedef struct list int data; struct list *next; SLIST; SLIST *creatlist(char*); void outlist(SLIST*); int fun(SLIST *h,char ch) SLIST *p;int n=0; p=h->next; /**********found**********/ while(p!= (1) ) n++; /**********found**********/ if(p->data==ch)return (2) ; else p=p->next; return 0; main() SLIST *head;int k;char ch; char a[N]='m','p','g','a','w','x','r,'d'; head=creatlist(a); outlist(head); printf("Enter a letter:"); scanf("%c", /**********found**********/ k=fun( (3) ); if(k==0)printf("/nNot found!/n"); else printf("The sequence number is:%d\n",k); SLIST *creatlist(char *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("/nThe list is NULL!/n"); else printf("haHead"); do printf("->%c",p->data); p=p->next; while(p!=NULL); printf("->End/n");
填空题给定程序中,函数fun的功能是调用随机函数产生20个互不相同的整数放在形参a所指数组中(此数组在主函数中已置0)。
请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。
注意:源程序存放在考生文件夹下的BLANK1.C中。
不得增行或删行,也不得更改程序的结构!
给定源程序如下。
#include<stdlib.h>
#include<stdio.h>
#define N 20
void fun(int *a)
{ int i,x,n=0;
x=rand()%20;
/*********found*******/
while(n<______)
{ for(i=0;i<n;i++)
/*************found**********/
if(x==a[i])______;
/**********found**********/
if(i==______){ a[n]=x;n++;}
x=rand()%20;
}
}
main()
{ int x[N]={0},i;
fun(x);
printf("The result:/n");
for(i=0;i<N;i++)
{ printf("%4d",x[i]);
if((i+1)%5==0)printf("/n");
}
printf("/n/n");
}
填空题请补充main函数,该函数的功能是:把一个字符串中的所有小写字母字符全部转换成大写字母字符,其他字符不变,结果保存原来的字符串中。
例如:当str[N]“123 abcdef ABCDEF!”,结果输出:
“123ABCDEFABCDEF!”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#define N 80
void main()
{
int j;
char str[N]="123abcdef ABCDEF!";
char *pf=str;
clrscr();
printf("*** original string ***/n");
puts(str);
{{U}} 【1】 {{/U}};
while(*(pf+j)).
{
if(*(pf+j)>='a'&&* (pf+j)<='z')
{
*(pf+j)={{U}} 【2】 {{/U}};
j++;
}
else
{{U}} 【3】 {{/U}};
}
printf("****** new string ******/n");
puts(str);
system("pause");
}
填空题当运行以下程序时,输入abcd,程序的输出结果是:______。insert(char str[]) int i;i=strlen(str);while(i>0) str[2*i]=str[i];str[2*i-1]='*';i--;printf("%s/n",str);main() char str[40]; scanf("%s",str);insert(str);
填空题在关系模型中,把数据看成是二维表,每一个二维表称为=个______。
填空题程序通过定义学生结构体数组,存储了若干名 学生的学号、姓名和三门课的成绩
填空题以下程序的输出结果是 【12】 。 void fun() static int a=0; a+=2; printf("%d",A) ; main() int cc; for(cc=1;CC<4;CC++)fun(); printf("/n");
填空题调用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】 测试方法和黑盒测试方法。
