回答編集履歴
1
追記
test
CHANGED
@@ -5,3 +5,27 @@
|
|
5
5
|
|
6
6
|
|
7
7
|
もしかして: int* と vector<int> は同じものと思っていますか?
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
```C++
|
12
|
+
|
13
|
+
void max(const std::vector<int>& v) {
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
std::vector<int>::const_iterator itr_max = std::max_element(v.begin(), v.end());
|
18
|
+
|
19
|
+
size_t max_index = std::distance(v.begin(), itr_max);
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
std::cout << "max element id=" << max_index << endl;
|
24
|
+
|
25
|
+
std::cout << "max element (hairetsu):" << v[max_index] << std::endl;
|
26
|
+
|
27
|
+
std::cout << "max element (pointer):" << *itr_max << std::endl;
|
28
|
+
|
29
|
+
}
|
30
|
+
|
31
|
+
```
|