请帮忙看一下这个很菜鸟的排序问题究竟是哪里错了~~

来源:百度知道 编辑:UC知道 时间:2024/06/08 00:22:04
网上的链表排序我都看不懂,所以只好自己写点……

#include <stdio.h>
#include <MALLOC.H>
#include <stdlib.h>
#define LEN sizeof(struct student)

struct student {
long number;
struct student *next;
};
int num;
static struct student *head;

void luru(){

struct student *p1,*p2;
num=0;
p1=p2=(struct student *)malloc(LEN);
scanf("%ld\n",&p1->number);

head=NULL;
while(p1->number!=0){
num++;
if(num==1)head=p1;
else p2->next=p1;
p2=p1;
p1=(struct student *)malloc(LEN);
scanf("%ld\n",&p1->number);

} p2->next=NULL;

}

infprintf(){
struct student *p1;
p1=head;
while(p1!=NULL){
printf("\n%ld",p1->number);
p1=p1->next;
}
}

main(){
int i,j;
long ave1,ave2;
struct student *p1,

C语言的看不懂,哈哈。
我编程工作4年了,还没遇到需要排序的地方。
这种算法,做练习还成,实际应用中,不是那么常用的。
另外这种编程问题,去CSDN更好一些~~
http://www.csdn.net