반응형
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <stack>
#include <vector>
#include <math.h>
#include <queue>
using namespace std;
struct Loc{
	int x, y, z;
	Loc(int a, int b, int c){
		x=a;
		y=b;
		z=c;	
	}
	bool operator<(const Loc &b)const{
		if(x!=b.x) return x<b.x;
		if(y!=b.y) return y<b.y;
		if(z!=b.z) return z<b.z;
		
	}
};


int main() {
	//freopen("input.txt.txt","rt",stdin);
	vector<Loc> XY;
	XY.push_back(Loc(2,3,5));
	XY.push_back(Loc(3,6,7));
	XY.push_back(Loc(2,3,5));
	XY.push_back(Loc(5,2,3));
	XY.push_back(Loc(3,1,6));
	
	
	for(auto pos : XY) {
		cout<<pos.x<<" "<<pos.y<<" "<<pos.z<<endl;
	}
	
	printf("---------------\n");
	
	sort(XY.begin(),XY.end());
	

	for(auto pos : XY) {
		cout<<pos.x<<" "<<pos.y<<" "<<pos.z<<endl;
	}
}
반응형

+ Recent posts