?? 9_1.txt
字號(hào):
#include<stdio.h>
typedef int keytp;
typedef struct node{
keytp data;
struct node *next;
}Lnode,*Link;
createlink(Link *h,int n)
{
int i;Link p,q;keytp key;
printf("請(qǐng)輸入關(guān)鍵字序列:\n");
for(i=0;i<n;i++)
{
scanf("%d",&key);
p=(Link)malloc(sizeof(Lnode));
p->data=key;
p->next=NULL;
if(*h==NULL)*h=p;
else
q->next=p;
q=p;
}
}
sortlink(Link *h)
{
keytp key;Link p,q,s;
if(*h==NULL)return 1;
p=*h;
while(p->next){
s=p;
q=p->next;
while(q){
if(q->data<s->data)s=q;
q=q->next;
}
if(s!=p){
key=s->data;
s->data=p->data;
p->data=key;
}
p=p->next;
}
}
display(Link h)
{
while(h){
printf("%d ",h->data);
h=h->next;
}
}
main()
{
int n;Link h=NULL;
printf("請(qǐng)輸入關(guān)鍵字序列中元素的個(gè)數(shù):\n");
do
scanf("%d",&n);
while(n<=0);
createlink(&h,n);
sortlink(&h);
printf("打印排好序的序列.\n");
display(h);
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -