반응형
#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;
}
}
반응형
'Algorithm > etc' 카테고리의 다른 글
recursion memoization (0) | 2022.01.18 |
---|---|
priority queue와 struct vector을 이용한 정렬 (0) | 2022.01.17 |
priority_queue : 우선순위 큐 , 최소힙, 최대힙 (0) | 2022.01.17 |
queue 직접구현, BFS (0) | 2022.01.16 |
[그래프] 인접 리스트(adjency list) 코드 구현 C++ (0) | 2022.01.15 |