参考代码:
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
map<int, int> ma;
typedef struct node
{
int data1;
int data2;
struct node* next;
}node;
int main()
{
int a, b, c;
cin >> a >> b;
c = a + b;
node* head = new node();
head->next = NULL;
node* last = head;
while (c--)
{
cin >> a >> b;
ma[a] = b;
}
vector<pair<int, int>> ne(ma.begin(), ma.end());
sort(ne.begin(), ne.end());
for (auto i = ne.begin(); i != ne.end(); i++)
{
node* temp = new node();
temp->next = NULL;
temp->data1 = i->first;
temp->data2 = i->second;
last->next = temp;
last = temp;
}
head = head->next;
while (head != NULL)
{
cout << head->data1 <<" " << head->data2 << endl;
head = head->next;
}
return 0;
}
0.0分
0 人评分
C语言程序设计教程(第三版)课后习题6.9 (C语言代码)浏览:1052 |
简单的a+b (C语言代码)浏览:674 |
1118(求助_已解决)浏览:351 |
罗列完美数 (C语言代码)浏览:519 |
The 3n + 1 problem (C语言代码)浏览:550 |
C语言程序设计教程(第三版)课后习题7.3 (C语言代码)浏览:569 |
C语言程序设计教程(第三版)课后习题11.3 (C语言代码)浏览:662 |
母牛的故事 (C语言代码)浏览:625 |
JAM计数法 (C语言代码)浏览:721 |
C语言程序设计教程(第三版)课后习题9.2 (C语言代码)浏览:646 |