#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stdlib.h>
#include <string.h>
using namespace std;
typedef struct Student
{
int number=-1;
int score=-1;
Student* next=NULL;
}*List,Node;
void init(List studetn)
{
studetn = (Node*)malloc(sizeof(Node));
studetn->next = NULL;
studetn->number = -1;
studetn->score = -1;
}
void add(List student,int number1,int score1)
{
Node* head = student; Node* temp;
while((head->next)!=NULL)
{
head = head->next;
}
temp = (Node*)malloc(sizeof(Node));
temp->next = NULL;
temp->number = number1;
temp->score = score1;
head->next = temp;
}
void And(List x, List y)
{
Node* head1 = x; Node* head2 = y;
while (head1->next&&head2->next!=NULL)
{
head1 = head1->next;
}
head1->next = head2->next;
}
int number(List a)
{
Node* head = a; int k = 0;
if (a->next==NULL)
{
return 0;
}
while (head->next)
{
k++;
head = head->next;
}
return k;
}
void sort1(List x)
{
Node* head2 = x; Node* temp;
int k = number(x);
for (int i=0;i<k;i++)
{
head2 = x;
while (head2->next)
{
temp = head2->next;
if (head2->number > temp->number)
{
int a = head2->number;
int b = head2->score;
head2->number = temp->number;
head2->score = temp->score;
temp->number = a;
temp->score = b;
}
head2 = head2->next;
}
}
}
void MyPrint(List x)
{
Node* next = x->next;
while (next)
{
printf("%d %d\n", next->number, next->score);
next = next->next;
}
}
int main()
{
int a, b, c, d;
cin >> a >> b;
List x=new Student ;List y=new Student;
init(x);
init(y);
for (int i = 0; i < a; i++)
{
cin >> c >> d;
add(x, c, d);
}
for (int i = 0; i < b; i++)
{
cin >> c>> d;
add(y, c, d);
}
And(x, y);
sort1(x);
MyPrint(x);
return 0;
}
0.0分
0 人评分