#include<iostream>
#include<stdlib.h>
#include<string.h>
using namespace std;
typedef struct node
{
int num;
int score;
struct node *next;
}Node;
Node *creatNode(int num,int score)
{
Node *newNode=(Node*)malloc(sizeof(Node));
newNode->num=num;
newNode->score=score;
newNode->next=NULL;
return newNode;
}
Node *insertNode(Node *head,Node *newNode)
{
if(head==NULL)
{
return newNode;
}
if(head->num>newNode->num)
{
newNode->next=head;
return newNode;
}
Node *current=head;
while(current->next!=NULL&¤t->next->num<=newNode->num)
{
current=current->next;
}
newNode->next=current->next;
current->next=newNode;
return head;
}
void print(Node *head)
{
while(head!=NULL)
{
cout<<head->num<<endl;
cout<<head->score<<endl;
head=head->next;
}
}
#include<stdlib.h>
#include<string.h>
using namespace std;
typedef struct node
{
int num;
int score;
struct node *next;
}Node;
Node *creatNode(int num,int score)
{
Node *newNode=(Node*)malloc(sizeof(Node));
newNode->num=num;
newNode->score=score;
newNode->next=NULL;
return newNode;
}
Node *insertNode(Node *head,Node *newNode)
{
if(head==NULL)
{
return newNode;
}
if(head->num>newNode->num)
{
newNode->next=head;
return newNode;
}
Node *current=head;
while(current->next!=NULL&¤t->next->num<=newNode->num)
{
current=current->next;
}
newNode->next=current->next;
current->next=newNode;
return head;
}
void print(Node *head)
{
while(head!=NULL)
{
cout<<head->num<<endl;
cout<<head->score<<endl;
head=head->next;
}
}