两个链表的连接问题 c高手请进
已有a,b两个链表,每个链表中的结点包括学号,成绩。要求把两个链表合并,按学号升序排列
连接函数有问题 请高手指点
#include <stdio.h>
#include <stdlib.h>
struct student{
int number;
int score;
struct student * next;
};
struct student * creat(){
int number;
int score;
struct student *head = NULL;
struct student *q = NULL;
struct student *p = NULL;
p = (struct student *)malloc(sizeof(struct student));
scanf("%d,%d",&number,&score);
while(number != NULL){
p->number = number;
p->score = score;
p->next = NULL;
if(head == NULL)
head = q = p;
else{
q->next = p;
q = p;
}
p = (struct student *)malloc(sizeof(struct student));
scanf("%d,%d",&number,&score);
}
p->next = NULL;
return head;
}
struct student * insert(struct student * ah,struct student * bh){
struct student * pa1, *pa2;
struct student * pb1, *pb2;
pa1 = pa2 = ah;
pb1 = pb2 = bh;
do{
while((pb2->number > pb1->number) && (pb1->next != NULL)){
pa2 = pa1;
pa1 = pa1->next;
}
pb2 = pb2->next;
pb1->next = pa1;
pa2->next = pb2;
pa2 = pa2->next;
pb2 = pb1
相关问答:
你还在新手阶段徘徊吗?你还在发愁应该怎么继续学习C和C++吗?
群 29152388 为你解开疑惑,欢迎新手老手的加入,你的加入就是其它人学习的动力
楼下出门踩便便
算你狠
新手的福音啊···终于 ......
const int num=100
float neiji(float [num]b, float [num]c)
{
int p;
float nj ......
C/C++ 2009-9专家榜
名次 专家名称 专家分 个人描述
1 mstlq (面色铁路桥) 5843 因为菜,所以努力学习中
2 whg01 (及时结贴是美德)&n ......
下面是我的代码 从内存写入文件正确 但从文件读入内存都是乱码 而且程序崩溃 请c高手指点
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct inf
{
& ......