C语言程序设计 程序填空题库及答案 下载本文

内容发布更新时间 : 2024/5/5 15:18:24星期一 下面是文章的全部内容请认真阅读。

data_in(person,5); data_out(person,5); }

data_in(struct man *p, int n ) { struct man *q = ① ; for( ;p

data_out( struct man *p, int n ) { struct man *q = __③__; for( ;p

printf(\;%u;%s\\n\;

}

【3.46】输入N个整数,储存输入的数及对应的序号,并将输入的数按从小到大的顺序进行排列。要求:当两个整数相等时,整数的排列顺序由输入的先后次序决定。例如:输入的第3个整数为5,第7个整数也为5,则将先输入的整数5排在后输入的整数5的前面。程序如下: #include \#define N 10 struct { int no; int num; } array[N]; main( )

{ int i,j,num; for( i=0;i

{ printf(\,i); scanf(\,&num);

for( ① ;j>=0&&array[j].num ② num; ③ ) array[j+1]=array[j]; array[ ④ ].num=num; array[ ⑤ ].no=i; }

for( i=0;i

printf(\,%d\\n\,i,array[i].num,array[i].no); }

【3.47】以下程序的功能是:读入一行字符(如:a、...y、z),按输入时的逆序建立一个链接式的结点序列,即先输入的位于链表尾(如下图),然后再按输入的相反顺序输出,并释放全部结点。

#include main( ) { struct node { char info; struct node *link; } *top,*p; char c; top=NULL;

while((c= getchar( )) ① )

{ p=(struct node *)malloc(sizeof(struct node)); p->info=c; p->link=top; top=p; }

while( top )

{ ② ; top=top->link; putchar(p->info); free(p); } }

【3.48】下面函数将指针p2所指向的线性链表,串接到末端。假定p1所指向的链表非空。 #define NULL 0 struct link { float a; struct link *next; };

concatenate ( p1,p2 )

p1所指向的链表的