Tavxela

Untitled

Jan 8th, 2020
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4.  
  5. using namespace std;
  6.  
  7. double myFunction(double);
  8. bool isEqual(double);
  9. void fillVector(vector<double>& vec) {
  10. double input;
  11.  
  12. for (int i = 0; i < 10; i++) {
  13. cout << "Enter integer: ";
  14. cin >> input;
  15. vec.push_back(myFunction(input));
  16. }
  17. }
  18.  
  19. int main() {
  20. int quantity = 0;
  21. vector<double> vec1;
  22.  
  23. fillVector(vec1);
  24. quantity = count_if(vec1.begin(), vec1.end(), [](double i) {return i == 12.25; });
  25.  
  26. cout << "Quantity of numbers which are equal to 12.25 is " << count_if(vec1.begin(), vec1.end(), isEqual) << '\n' << quantity << endl;
  27. }
  28.  
  29. bool isEqual(double i) {
  30. return i == 12.25;
  31. }
  32.  
  33. double myFunction(double x) {
  34. if (x < 3) {
  35. return x *= 5;// ან x = x * 5;
  36. }
  37. else if (x > 3) {
  38. return x -= 3;
  39. }
  40. else if (x = 3) {
  41. return x;
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment