回答編集履歴
1
追記
test
CHANGED
@@ -33,3 +33,63 @@
|
|
33
33
|
}
|
34
34
|
|
35
35
|
```
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
---
|
40
|
+
|
41
|
+
【追記】
|
42
|
+
|
43
|
+
あああ、ゆったり書いている内に被ってしまいました。
|
44
|
+
|
45
|
+
all_ofの再実装になるのでやるべきではないですが、こんなアイデアもあるという意味で、ラムダ式を使う案も載せておきます。
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
```C++
|
50
|
+
|
51
|
+
#include <iostream>
|
52
|
+
|
53
|
+
#include <algorithm>
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
int main()
|
58
|
+
|
59
|
+
{
|
60
|
+
|
61
|
+
// char temp[]={0, 1, 2};
|
62
|
+
|
63
|
+
char temp[]={0, 0, 0};
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
auto isZero=
|
68
|
+
|
69
|
+
[](auto const& array)
|
70
|
+
|
71
|
+
{
|
72
|
+
|
73
|
+
for (auto x:array)
|
74
|
+
|
75
|
+
if (x!=0)
|
76
|
+
|
77
|
+
return false;
|
78
|
+
|
79
|
+
return true;
|
80
|
+
|
81
|
+
};
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
if ( isZero(temp) )
|
86
|
+
|
87
|
+
std::cout << "all zero\n";
|
88
|
+
|
89
|
+
else
|
90
|
+
|
91
|
+
std::cout << "not zero\n";
|
92
|
+
|
93
|
+
}
|
94
|
+
|
95
|
+
```
|