#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 人评分
C语言网提供由在职研发工程师或ACM蓝桥杯竞赛优秀选手录制的视频教程,并配有习题和答疑,点击了解:
一点编程也不会写的:零基础C语言学练课程
解决困扰你多年的C语言疑难杂症特性的C语言进阶课程
从零到写出一个爬虫的Python编程课程
只会语法写不出代码?手把手带你写100个编程真题的编程百练课程
信息学奥赛或C++选手的 必学C++课程
蓝桥杯ACM、信息学奥赛的必学课程:算法竞赛课入门课程
手把手讲解近五年真题的蓝桥杯辅导课程
发表评论 取消回复