填空题把a1、a2定义成双精度实型变量,并赋初值1的定义语句是______。
填空题函数pi的功能是根据以下近似公式求π值:
(π*π)/6=1+1/(2*2)+1/(3*3)+...+1(n*n)
现在请你在下面的函数中填空,完成求π的功能。
#include "math.h"
{ double s=0.0; long i;
for(i=1;i<=n;i++)s=s+{{U}} 【7】 {{/U}};
return(sqrt(6*S));
}
填空题Windows窗口一般由标题栏、菜单栏、控制按钮等部分组成。为了移动窗口,则要用鼠标拖动{{U}} 【3】 {{/U}} 。
填空题在线性表的顺序存储中,元素之间的逻辑关系是通过 【2】 决定的;在线性表的链接存储中,元素之间的逻辑关系是通过 【3】 决定的。
填空题在线性结构中,队列的操作顺序是先进先出,而栈的操作顺序是{{U}} 【2】 {{/U}}。
填空题程序通过定义学生结构体变量,存储了学生的学号、姓名和三门课的成绩。所有学生数据均以二进制方式输出到文件中。函数fun的功能是从形参filename所指的文件中读入学生数据,并按照学号从小到大排序后,再用二进制方式把排序后的学生数据输出到filename所指的文件中,覆盖原来的文件内容。
请在程序的下画线处填入正确的内容并把下画线删除,使程序得出正确的结果。
注意:不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdio.h>
#define N 5
typedef struct student{
long sno;
char name[10];
float score[3];
}STU;
void fun(char*filename)
(FILE*fp;int i,j;
STU s[N],t;
/*********found*********/
fp=fopen(filename,______);
fread(s,sizeof(STU),N,fp);
fclose(fp);
for(i=0;i<N-1;i++)
for(j=i+1;j<N;j++)
/*********found*********/
if(s[i].sno______s[j].sno)
{t=s[i];s[i]=s[j];
s[j]=t;}
fp=fopen(filename,"wb");
/*********found*********/
______(s,sizeof(STU),N,fp);
fclose(fp);
}
main()
{STU t[N]={{10005,"ZhangSan",95,80,88},{10003,"LiSi",85,70,78},{10002,"CaoKai",75,60,88},{10004,"FangFang",90,82,87},{10001,"MaChao",91,92,77}},ss[N];
int i,j;FILE*fp;
fp=fopen("student.dat","wb");
fwrite(t,sizeof(STU),5,fp);
fclose(fp);
printf("/n/nThe original data:/n/n");
for(j=0;j<N;j++)
{printf("/nNo:%ld Name:%-8s
Scores:",t[j].sno,t[j].name);
for(i=0;i<3;i++)
printf("%6.2f",t[j].score[i]);
printf("/n");
}
fun("student.dat");
printf("/n/nThe data after sorting:/n/n");
fp=fopen("student.dat","rb");
fread(ss,sizeof(STU),5,fp);
fclose(fp);
for(j=0;j<N;j++)
{printf("/nNo:%ld Name:%-8sScores:",ss[j].sno,ss[j].name);
for(i=0;i<3;i++)
printf("%6.2f",ss[j].score[i]);
printf("/n");
}
}
填空题下列程序的输出结果是______。 #include<stdio.h> fun() static int a=0; a+=3;printf("%d",A) ; main() int cc; for(cc=1;cc<5;cc++)fun(); printf("/n");
填空题以下程序的输出结果是{{U}} 【7】 {{/U}}。
main()
{ unsigned short a=65536; int b;
printfC%d/n",b=a);
}
填空题请补充fun函数,该函数的功能是:将带头结点的单向链表逆置。即若原链表中从头至尾结点数据域依次为:2、4、6、8、10,逆置后,从头至尾结点数据域依次为:10、8、6、4、2。
[注意] 部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。
[试题源程序] #include <stdio.h>
#include <stdlib.h> #define N 5 typedef Struct
node { int data; struct node
*next; }NODE; void fun(NODE
*h) { NODE *p, *q, *r;
p={{U}} {{U}} {{/U}} {{/U}}; if ({{U}}
{{U}} {{/U}} {{/U}}) return; q=P->next;
P->next=NULL; while (q) {
r=q->next; q->next=p; p=q;
q={{U}} {{U}} {{/U}} {{/U}};
} h->next=p; } NODE *creatlis
(int a[]) { NODE *h, *p, *q; int
i; h= (NODE *)malloc(sizeof(NODE));
h>next=NULL: for(i=0; i<N; i++) {
q=(NODE *)malloc(sizeof(NODE)); q->data=a[i];
q->next=NULL; if(h->next==NULL)
h->next=p=q; else {
p->next=q; p=q; } } return
h; } void ou list(NODE *h)
{ NODE *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"); } }
main() { NODE *head; int
a[N]=(2, 4, 6, 8, 10); head=creatlist(a);
printf('/nThe original list:/n"); outlist(head);
fun(head); printf("/nThe list after inverting
:/n"); outlist(head);}
填空题从Windows环境进入MS-DOS方式后,返回Windows环境的DOS命令为
【4】
。
填空题下列给定程序中已建立一个带头节点的单向链表,链表中的各节点按节点数据域中的数据递增有序链接。函数fun的功能是:把形参x的值放入一个新节点并插入链表中,使插入后各节点数据域中的数据仍保持递增有序。
请在程序的下划线处填入正确的内容,使程序得出正确的结果。
注意:部分源程序给出如下。
不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdio.h>
#include<stdlib.h>
#define N 8
typedef struet list
{ int data;
struet list *next;
}SLIST;
void fun(SLIST *h,int x)
{ SLIST *p,*q,%s;
s=(SLIST *)malloe(sizeof(SLIST));
/********found********/
s->data=______;
q=h;
p=h->next;
while(p!=NULL
p=p->next;
}
s->next=p;
/********found********/
q->next=______;
}
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("/nThe list is NULL!/n");
else
{ printf("/nHead");
do {printf("->%d",p->data);
p=p->next;
}while(p!=NULL);
printf("->End/n");
}
}
main()
{ SLIST *head; int x;
int a[N]={11,12,15,18,19,22,25,29};
head=creatlist(a);
printf("/nThe list before inserting:/n");
outlist(head);
printf("/nEnter a number:");
scanf("%d",
fun(head,x);
printf("/nThe list after inserting:/n");
outlist(head);
}
填空题给定程序中,函数fun的功能是:将形参指针所指结构体数组中的三个元素按num成员进行升序排列。
请在程序的下划线处填入正确的内容并把下戈线删除,使程序得出正确的结果。
注意
:部分源程序给出如下。
不得增行或删行,也不得更改程序的结构!
试题程序:
#include <stdio.h>
typedef struct
{int num;
char name[10];
}PERSON;
/********found********/
void fun(PERSON ______,
{
/********found********/
______temp;
if(std[0].num>std[i].num)
{temp=std[0]; std[0]=std[1];
std[1]=temp;}
if(std[0].num>std[2].num)
{temp=std[0]; std[0]=std[2];
std[2]=temp;}
if(std[1].num>std[2].num)
{temp=std[1]; std[1]=std[2];
std[2]=temp;}
}
main()
{PERSON std[]=(5,"Zhanghu",2,"WangLi",6,"LinMin"};
int i;
/********found********/
fun(______);
printf("The result is":);
for(i=0;i<3;i++)
printf("%d,%s",std[i].num,std[i].name);
}
填空题以下程序运行后的输出结果是 {{U}} 【15】 {{/U}}
int a=5;
fun(int b)
{ static int a=10;
a+=b++;
printf("%d ",a);
}
main( )
{ int c=20;
fun(c);
a+=c++;
printf("%d/n",a);
}
填空题单元测试又称模块测试,一般采用【 】测试。
填空题函数mycmp(char *s,char *t)的功能是比较字符串s和t的大小,当s等于t时返回0,当s>t时返回正值,当s<t时返回负值。请填空。
mycmp( char *s,char *t)
{ while ( *s==*t)
{ if(*s= ='/0') return 0;
++s; ++t;
}
return({{U}} 【11】 {{/U}});
}
填空题如果一个工人可管理多个设施,而一个设施只可被一个工人管理,则实体“工人”与实体“设备”之间存在 【1】 联系。
填空题一棵二叉树第六层(根结点为第一层)的结点数最多为个______。
填空题下列程序的输出结果是{{U}} {{/U}}。 main() int a[]=2,4,6,*ptr= for(y=0;y<3;y++) z=(*(ptr+y)<x)?*(ptr+y):x; printf("%d//n",z);
填空题下面程序将二维数组a的行和列元素互换后存放到另一个二维数组b中,请填空。 main() int a[2][3]=1,2,3,4,5,b[3][2],i,j; for(i=0;i<2;i++) for(j=0;j<3;j++) ______;
填空题下列程序的功能是对输入的一行字符中的数字字符的字面值累加,输出此累加和,请填空。 #include<stdio.h> #include<ctype.h> main() char c; int a,s=0; while(______) if(isdigit(C) ) a=c-'0';s+=a; printf("s=%d",s);
