liujiesmart 发布留言 2008-6-28 20:19 跪求高手帮忙改下程序多关键字排序 我代码没错,就是运行不下去,高手帮忙看看,出哪了问题!!帮忙改下[em04] #include #include #include #include #include #define Null 0 #define r 101 typedef struct node { int k[6]; struct node *next; char name; }Rnode,*Rlink; void Radixsort(Rlink F,int gs)/*基数排序*/ { Rlink p,t,f[r],e[r]; int i,j; if(F->next==Null)return; for(i=gs;i>=1;i--) { for(j=0;j<=r;j++) f[j]=Null; p=F->next; while(p) { j=p->k==Null)f[j]=p; else e[j]->next=p; e[j]=p; p=p->next; } for(j=0;!f[j];j++) F->next=f[j]; t=e[j]; while(j { j++; if(f[j]) { t->next=f[j]; t=e[j]; } } t->next=Null; } } void Linsertsort(Rnode *L,int i) { Rlink p,q,s,u; p=L->next; L->next=Null; while(p) { s=L;q=L->next; while(q&&q->k) { s=q;q=q->next; } u=p->next; p->next=q; s->next=p; p=u; i--; while(i>=1) Linsertsort(L,i); } } int initl(Rnode *head)/*建立空表*/ { head=(Rnode*)malloc(sizeof(Rnode)); if(head==Null)return 0; head->next=Null; return 1; } int Great(Rnode *head,Rnode a[],int n,int nu)/*建立链表*/ { Rnode *p,*s; int j,i; if(initl(head)==0)return 0; p=head; for(j=0;j<=n-1;++j) { if((s=(Rnode*)malloc(sizeof(Rnode)))==Null)return 0; for(i=1;i<=nu;i++) s->k.k.name; s->next=Null; p->next=s; p=s; } return 1; } main() { int num,i,numb,War; Rnode b[1000];Rlink LB; printf("\nPlease choose the way of problem:");/*选择方法*/ scanf("%d",&War); printf("\nPlease input the number of student(<=1000):"); scanf("%d",&num); printf("\nPlease input the number of school subject course(<=5):"); scanf("%d",&numb); for(i=1;i<=num;i++) { printf("\nPlease input the name of student%d:",i); getchar(); scanf("%c",&b.k[1]); } if(numb>=2) {
printf("\nPlease input the second important scorce:"); scanf("%d",&b); } if(numb>=3) { printf("\nPlease input the third important scorce:"); scanf("%d",&b); } if(numb>=4) { printf("\nPlease input the fourth important scorce:"); scanf("%d",&b); } if(numb>=5) { printf("\nPlease input the fifth important scorce:"); scanf("%d",b); } } Great(LB,b,num,numb); while(War==1) { Radixsort(LB,numb); for(i=0;i { printf("\nThe result is number %d: %s",i+1,LB->name); LB=LB->next; } } while(War==2) { Linsertsort(LB,numb); for(i=0;i { printf("\nThe result is number %d: %s",i+1,LB->name); LB=LB->next; } } }qGemini 发布留言 2008-6-28 20:27 写得好乱啊liujiesmart 发布留言 2008-6-28 20:37 没人愿意看下去呀[em04] [em04]himpo 发布留言 2008-6-28 20:39 你要是排一下版后可能好点。。。qGemini 发布留言 2008-6-28 20:44 同意![tk05]liujiesmart 发布留言 2008-6-28 21:13 [em04] [em04]
页: [1] 特别说明:如网页特效代码中有引用图片文件等,请自己下载到本地调试! |