两个链表的连接问题 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
相关问答:
struct s1 {
char ch, *ptr;
union {
short a, b;
unsigned int c:2, d:1;
}
struct s1 *next;
};
主要看不懂符号 :
请达人指点一二
http://blog.cechina.cn/true ......
开始学OS,按练习要求写的代码在gcc下无法编译:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
void SIGFPEhandler2(int s ......
在C语言中如何打开一个已知的文件。如打开名为add.txt的文件假设它在C:\\Promgram Files\add.txt.要求打开时不改变其里面的内容。高手请解答下啊
fopen( "C:\\Promgram Files\add.txt" , "rb" ......
编译普通的c没问题啊,但编译javah生成的就报错:
gcc -O0 -g3 -Wall -c -fmessage-length=0 -oHelloWorld.o ..\HelloWorld.c
gcc -otest.exe HelloWorld.o
d:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../. ......