-
Notifications
You must be signed in to change notification settings - Fork 0
/
stlpractice.cpp
85 lines (74 loc) · 1.97 KB
/
stlpractice.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include<bits/stdc++.h>
#include<string>
using namespace std;
struct data {
string name;
int height, weight;
long long income;
};
bool compare( data a, data b ) {
if( a.income == b.income ) {
if( a.height == b.height ) {
if( a.weight == b.weight ){
int x, y;
//x = size(a.name);
x = a.name.size();
//y = size(b.name);
y = b.name.size();
if(x < y)
return true;
else
return false;
}
else return a.weight < b.weight;
}else return a.height > b.height;
}else return a.income > b.income;
}
int main(){
int a, n;
vector <data> patro;
cin >> n;
for(int i = 0; i<n; i++){
patro.push_back(data());
cin >> patro[i].name >> patro[i].height >> patro[i].weight >> patro[i].income;
}
sort(patro.begin(), patro.end(), compare);
/*vector <int> v;
vector <int> :: iterator it;
priority_queue <int> pq;
for(int i = 0; i < n; i++){
cin >> a;
v.push_back(a);
pq.push(a);
}
for(it = v.begin(); it != v.end(); it++){
cout << " " << *it << endl;
}
while(!pq.empty()){
cout << " " << pq.top() << endl;
pq.pop();
}*/
vector <data> :: iterator it;
for(int i = 0; i<n; i++){
//patro.push_back(data());
cout << " " << patro[i].name << " " << patro[i].height << " " << patro[i].weight << " " << patro[i].income << endl;
}
return 0;
}
/*
map< string, int > m;
string goru;
while( cin >> goru ) {
if( goru == "moro" ) break;
m[ goru ] ++;
cout << goru <<" ase " << m[ goru ] << " ta :D " << endl;
}
char line[1000];
while( gets( line ) ) {
stringstream ss( line ); // initialize kortesi
int num; vector< int > v;
while( ss >> num ) v.push_back( num ); // :P
sort( v.begin(), v.end() );
// print routine
}
*/