Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //3-ის ჯერადების რაოდენობა 100 ელემენტიანი ვექტორიდან.
- #include <iostream>
- #include <vector>
- #include <ctime>
- using namespace std;
- bool isMultiple_3(const int);//ბულიონის პროტოტიპი
- int Count(const vector<int>, bool f(int));//პროტოტიპი ითვლის 3-ის ჯერადებს
- int main()
- {
- vector<int> a;
- for (int i = 0; i < 100; ++i)
- a.push_back(rand());
- cout << "3-is jeradebis raodenoba = "
- << Count(a, isMultiple_3) << endl;
- }
- //ფუნქცია, რომელიც ეძებს 3-ის ჯერადებს
- bool isMultiple_3(const int x)
- {
- return x % 3 == 0;
- }
- //ფუნქცია, რომელიც ითვლის 3-ის ჯერადებს
- int Count(const vector<int> x, bool f(int))
- {
- int counter = 0;
- for (int i = 0; i < x.size(); ++i)
- if (f(x[i])) counter++;
- return counter;
- }
Advertisement
Add Comment
Please, Sign In to add comment