回答編集履歴
3
微修正
test
CHANGED
@@ -142,7 +142,7 @@
|
|
142
142
|
|
143
143
|
return a.hori_angle < b.hori_angle ||
|
144
144
|
|
145
|
-
(!(
|
145
|
+
(!(b.hori_angle < a.hori_angle ) && a.vertical_angle < b.vertical_angle);
|
146
146
|
|
147
147
|
});
|
148
148
|
|
2
追記
test
CHANGED
@@ -109,3 +109,59 @@
|
|
109
109
|
}
|
110
110
|
|
111
111
|
```
|
112
|
+
|
113
|
+
[追記] 第三版
|
114
|
+
|
115
|
+
```C++
|
116
|
+
|
117
|
+
#include <iostream>
|
118
|
+
|
119
|
+
#include <algorithm>
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
class point {
|
124
|
+
|
125
|
+
public:
|
126
|
+
|
127
|
+
double hori_angle; //xy平面上でのx軸と点の角度(以下、水平角)
|
128
|
+
|
129
|
+
double vertical_angle; //xy平面と点のなす角度(以下、垂直角)
|
130
|
+
|
131
|
+
};
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
int main() {
|
136
|
+
|
137
|
+
point data[5][7] = { ... };
|
138
|
+
|
139
|
+
std::sort((point*)data, (point*)data+5*7,
|
140
|
+
|
141
|
+
[](const point& a, const point& b) {
|
142
|
+
|
143
|
+
return a.hori_angle < b.hori_angle ||
|
144
|
+
|
145
|
+
(!(a.hori_angle < b.hori_angle ) && a.vertical_angle < b.vertical_angle);
|
146
|
+
|
147
|
+
});
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
// できたかな?
|
152
|
+
|
153
|
+
for ( int row = 0; row < 5; ++row ) {
|
154
|
+
|
155
|
+
for ( int col = 0; col < 7; ++col ) {
|
156
|
+
|
157
|
+
std::cout << data[row][col].hori_ange << ',' << data[row][col].vertical_angle << ' ';
|
158
|
+
|
159
|
+
}
|
160
|
+
|
161
|
+
std::cout << std::endl;
|
162
|
+
|
163
|
+
}
|
164
|
+
|
165
|
+
}
|
166
|
+
|
167
|
+
```
|
1
追記
test
CHANGED
@@ -45,3 +45,67 @@
|
|
45
45
|
}
|
46
46
|
|
47
47
|
```
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
[追記] 第二版
|
52
|
+
|
53
|
+
```C++
|
54
|
+
|
55
|
+
#include <iostream>
|
56
|
+
|
57
|
+
#include <algorithm>
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
class point {
|
62
|
+
|
63
|
+
public:
|
64
|
+
|
65
|
+
int angle;
|
66
|
+
|
67
|
+
point(int a) : angle(a) {};
|
68
|
+
|
69
|
+
};
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
int main() {
|
74
|
+
|
75
|
+
point data[5][7] = {
|
76
|
+
|
77
|
+
{ 0, 0, 0, 1, 2, 0, 0 },
|
78
|
+
|
79
|
+
{ 1, 3, 2, 1, 0, 4, 3 },
|
80
|
+
|
81
|
+
{ 0, 1, 1, 4, 1, 1, 4 },
|
82
|
+
|
83
|
+
{ 2, 2, 4, 3, 2, 3, 2 },
|
84
|
+
|
85
|
+
{ 2, 3, 4, 4, 3, 3, 4 },
|
86
|
+
|
87
|
+
};
|
88
|
+
|
89
|
+
std::sort((point*)data, (point*)data+5*7,
|
90
|
+
|
91
|
+
[](const point& a, const point& b) { return a.angle < b.angle; });
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
// できたかな?
|
96
|
+
|
97
|
+
for ( int row = 0; row < 5; ++row ) {
|
98
|
+
|
99
|
+
for ( int col = 0; col < 7; ++col ) {
|
100
|
+
|
101
|
+
std::cout << data[row][col].angle << ' ';
|
102
|
+
|
103
|
+
}
|
104
|
+
|
105
|
+
std::cout << std::endl;
|
106
|
+
|
107
|
+
}
|
108
|
+
|
109
|
+
}
|
110
|
+
|
111
|
+
```
|