填空题以下程序的输出结果是{{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);
填空题以下程序的功能是对从键盘上输入的两个字符串进行比较,然后输出两个字符串中第一个不相同字符的ASCII码值之差。请填空。 #include"stdio.h" main() char a1[20],a2[20]; int n=0,t; scanf("%st",a1); scanf("%s",a2); while(a1[n]!=a2[n]&&(a1[n]!= 【15】 )) t= 【16】 ; printf("%d/n",t); n++;
填空题现有两个C程序文件T18.C和myfun.C同在TC系统目录(文件夹)下,其中T18.C文件如下:
#include
#include"myfun.c"
main()
{fun();printf("\n");}
myfun.C文件如下:
void fun()
{char S[80],C;int n=0; while((C=getchar())!=''\n'')S[n++]=c;
n--;
while(n>=0)prinff("%C",s[n-]);
}
当编译连接通过后,运行程序T18时,输入Thank!则输出结果是:【 】。
填空题有以下定义和语句,则sizeof(a)的值是______,而sizeof(a.share)的值是______。 struct date int day; int mouth; int year; unionint share1; float share2; share; a;
填空题下列给定的程序中,函数proc()的功能是:判断字符ch是否与str所指字符串中的某个字符相同,若相同,则什么也不做,若不同,则将其插在串的最后。 请修改程序中的错误,使它能得出正确的结果。 注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构。 试题程序: #include<stdlib.h> #include<conio.h> #include<stdio.h> #include<string.h> //************found************* void proc(char str, char eh) while(*str //************found************* if(*str==ch) str[0]=ch; //************found*********** str[1]='0'; void main() char str[81], ch; system("CLS"); printf("/nPlease enter a string: "); gets(str); printf("/n Please enter the character to search:"); ch=getchar(); proc(str, oh); printf("/nThe result is%s/n", str);
填空题下面的if语句与y=(x>=10)?3*x-11:(x<1)?x:2*x-1;的功能相同,请补充完整。 if( 【10】 ) if( 【11】 )y=2*x-1; else y=x; else y=3*x-11;
填空题设一棵完全二叉树共有700个结点,则在该二叉树中有______个叶子结点。
填空题若有定义:int x=3, y=4; ,则表达式!x||y的值为______。
