两个链表的连接问题 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
相关问答:
给一个字符串、例如 “ababc”要求返回“ab”. 因为“ab”连续重复出现且最长。 用C/C++语言写一函数完成该算法,给出复杂度
这个题我不会
C/C++ code:
#include <iostream>
#include <s ......
本人对C特别感兴趣,希望志同道合的人一起交流,另外还可以一起讨论linux问题
QQ群:17409844
有兴趣的同志加下
顶个.
帮顶……
不过确实对群失望了>_ <
顶上
顶一个
请接受啊
&nbs ......
大家帮我看看这个代码,有很多问题,不知道怎么改,小弟在此谢谢了。
#include <stdio.h>
#include <conio.h>
#include <ctype.h>
float date1,date2;
char op;
void ......
写了一段程序
C/C++ code:
..
MYSQL* mysql;
MYSQL_RES* res;
//我想实现一个查看有没有 mysql结构,如果没有就连接。
void connect()
{
mysql_init(mysql);
mysql_realconnect(. ......