teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

追記

2018/01/23 17:25

投稿

totake
totake

スコア6

title CHANGED
File without changes
body CHANGED
@@ -16,4 +16,38 @@
16
16
  int sum = std::accumulate(v.begin(), v.end(), 0);
17
17
  std::cout << "sum : " << sum << std::endl;
18
18
  }
19
+ ```
20
+ ```C++
21
+ #include <string>
22
+ #include <vector>
23
+ #include <algorithm>
24
+ #include <iostream>
25
+
26
+ struct score {
27
+ std::string name;
28
+ int aaa;
29
+ int bbb;
30
+ int ccc;
31
+
32
+ score(std::string n, int a, int b, int c) :
33
+ name(n), aaa(a), bbb(b), ccc(c) {}
34
+ };
35
+
36
+
37
+ class score_a {
38
+ public:
39
+ bool operator()(const score& value) const {
40
+ return value.aaa ;
41
+ }
42
+ };
43
+
44
+ int main() {
45
+ std::vector<score> v1;
46
+ v1.push_back(score("青木", 5, 10, 15));
47
+
48
+ int tokuten = std::count_if(v1.begin(), v1.end(), score_a());
49
+ std::cout << "青木:" << tokuten << std::endl;
50
+
51
+ return 0;
52
+ }
19
53
  ```