Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as C++ by s.r ( 15 years ago )
#include <iostream>
#include <algorithm>
#include <time.h>
#include <vector>
using namespace std;
struct t {
int y, x;
};
bool operator< (const t& a, const t& b) {
return a.y < b.y;
}
ostream& operator << (ostream& stream, t &k) {
stream << '(' << k.x << ',' << k.y << ')';
return stream;
}
int main (int argc, char const* argv[]) {
srand(time(NULL));
vector<t> a;
a.resize(10);
for (int i = 0; i < a.size(); i += 1) {
a[i].x = rand() % 100;
a[i].y = rand() % 100;
cout << a[i] << ' ';
}
cout << endl;
sort(a.begin(), a.end());
for (int i = 0; i < a.size(); i += 1)
cout << a[i] << ' ';
return 0;
}
Revise this Paste