46 lines
891 B
C++
46 lines
891 B
C++
/* STL */
|
|
#include <algorithm>
|
|
#include <deque>
|
|
#include <functional>
|
|
#include <iterator>
|
|
#include <list>
|
|
#include <map>
|
|
#include <memory>
|
|
#include <numeric>
|
|
#include <queue>
|
|
#include <set>
|
|
#include <stack>
|
|
#include <utility>
|
|
#include <vector>
|
|
/* STD */
|
|
#include <iostream>
|
|
#include <string>
|
|
#include <cstdlib>
|
|
#include <math.h>
|
|
using namespace std;
|
|
|
|
// Объединяем записи, используя имена в качестве ключей
|
|
|
|
struct entry {
|
|
long nr;
|
|
char name[30];
|
|
bool operator<(const entry &b) const {
|
|
return strcmp(name, b.name) < 0;
|
|
}
|
|
};
|
|
|
|
int main (int argc, char *argv[]) {
|
|
entry a[3] = {{10, "Betty"},
|
|
{11, "James"},
|
|
{80, "Jim"}},
|
|
b[2] = {{16, "Fred"},
|
|
{20, "William"}},
|
|
c[5], *p;
|
|
merge(a, a+3, b, b+2, c);
|
|
for (p=c; p != c+5; p++)
|
|
cout << p->nr << " " << p->name << endl;
|
|
cout << endl;
|
|
return 0;
|
|
}
|
|
|