Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- using namespace std;
- double myFunction(double);
- bool isEqual(double);
- void fillVector(vector<double>& vec) {
- double input;
- for (int i = 0; i < 10; i++) {
- cout << "Enter integer: ";
- cin >> input;
- vec.push_back(myFunction(input));
- }
- }
- int main() {
- int quantity = 0;
- vector<double> vec1;
- fillVector(vec1);
- quantity = count_if(vec1.begin(), vec1.end(), [](double i) {return i == 12.25; });
- cout << "Quantity of numbers which are equal to 12.25 is " << count_if(vec1.begin(), vec1.end(), isEqual) << '\n' << quantity << endl;
- }
- bool isEqual(double i) {
- return i == 12.25;
- }
- double myFunction(double x) {
- if (x < 3) {
- return x *= 5;// ან x = x * 5;
- }
- else if (x > 3) {
- return x -= 3;
- }
- else if (x = 3) {
- return x;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment