问题描述
如何插入到 list=NULL;在 c 中按降序排列??
注意 我用这个函数插入空列表 我想在短时间内插入代码的小空间
typedef struct node *nodeptr;
struct node
{
int s_num;
float avg;
char branch[9];
nodeptr next;
};
typedef nodeptr LIST;
typedef nodeptr Position;
//This function for inser in ascending order
void insert(LIST l,nodeptr temp){
nodeptr ptr;
if(isEmpty(l) || l->next->avg >= temp->avg){
temp->next=l->next;
l->next = temp;
}
else{
ptr =l->next;
while(ptr->next != NULL && ptr->next->avg < temp->avg){
ptr=ptr->next;
}
temp->next=ptr->next;
ptr->next=temp;
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)