#include 〃stdio。h〃
#include 〃graphics。h〃
#include 〃conio。h〃
main()
{
int x=360;y=160;driver=VGA;mode=VGAHI;
int num=20;i;
int top;bottom;
initgraph(&driver;&mode;〃〃);
top=y…30;
bottom=y…30;
for(i=0;inext;
while(ptr!=NULL)
{ printf(〃The value is 》%dn〃;ptr…》data);
ptr=ptr…》next;
}}
【程序74】
题目:连接两个链表。
1。程序分析:
2。程序源代码:
#include 〃stdlib。h〃
#include 〃stdio。h〃
struct list
{ int data;
struct list *next;
};
typedef struct list node;
typedef node *link;
link delete_node(link pointer;link tmp)
{if (tmpNULL) /*delete first node*/
return pointer…》next;
else
{ if(tmp…》next…》nextNULL)/*delete last node*/
tmp…》next=NULL;
else /*delete the other node*/
tmp…》next=tmp…》next…》next;
return pointer;
}
}
void selection_sort(link pointer;int num)
{ link tmp;btmp;
int i;min;
for(i=0;idata;
btmp=NULL;
while(tmp…》next)
{ if(min》tmp…》next…》data)
{min=tmp…》next…》data;
btmp=tmp;
}
tmp=tmp…》next;
}
printf(〃40: %dn〃;min);
pointer=delete_node(pointer;btmp);
}
}
link create_list(int array'';int num)
{ link tmp1;tmp2;pointer;
int i;
pointer=(link)malloc(sizeof(node));
pointer…》data=array'0';
tmp1=pointer;
for(i=1;inext=NULL;
tmp2…》data=array'i'