-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhello_sort_stdio.cpp
More file actions
74 lines (52 loc) · 1.28 KB
/
Copy pathhello_sort_stdio.cpp
File metadata and controls
74 lines (52 loc) · 1.28 KB
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
#include <stdint.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <cstdio>
typedef int* iterator_t;
struct less_t {
bool operator() (const int& lhs, const int& rhs) const {
return lhs < rhs;
}
};
bool less_func(const int& lhs, const int& rhs) {
return lhs > rhs;
}
//(bool)less_func_t(const int& lhs, const int& rhs);
//typedef less_func_t less_t;
//template <typename less_type>
//void sort(iterator_t &begin, size_t size, less_type const &less);
template <typename less_type>
void sort(iterator_t begin, iterator_t end, less_type const &less) {
std::sort(begin, end, less);
}
/*
template <typename less_type>
void sort(iterator_t &begin, size_t size, less_t const &less) {
iterator_t end = begin;
for (size_t i = 0; i < size; ++i) {
++end;
// end = it + 1;
}
std::sort(begin, end, less);
}
*/
int main() {
std::vector<int> data;
// while (1) {
for(;;) {
std::string line;
std::getline(std::cin, line);
int value = 0;
sscanf(line.c_str(), "%d", &value);
// std::cin >> value;
if (std::cin.eof()) break;
data.push_back(value);
}
less_t less;
sort<less_t>(&data[0], &data[data.size()], less);
for (size_t i = 0; i < data.size(); ++i) {
std::cout << data[i] << std::endl;
}
return 0;
}