Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <numeric>
- #include <vector>
- int main()
- {
- std::vector<int> v(101);
- std::vector<int> result;
- int count = 0;
- std::iota(v.begin(), v.end(), 1);
- for (const auto& e : v) {
- if (e % 3 == 0) {
- result.push_back(e);
- count++;
- }
- }
- std::cout << "3の倍数の個数は" << count << "個" << std::endl;
- // 表示結果: "3の倍数の個数は33個"
- }
Advertisement
Add Comment
Please, Sign In to add comment