33 lines
472 B
C++
33 lines
472 B
C++
#include <iostream>
|
|
|
|
using namespace std;
|
|
|
|
void filterIntArray(int x[], int size, bool (*condition)(int),
|
|
int (*op)(int)){
|
|
for(int i = 0; i < size; i++){
|
|
if(condition(x[i])){
|
|
x[i] = op(x[i]);
|
|
}
|
|
}
|
|
}
|
|
|
|
bool odd(int n){
|
|
return n % 2 == 1;
|
|
}
|
|
|
|
int addOne(int n){
|
|
return n + 1;
|
|
}
|
|
|
|
int main(){
|
|
int heck[] = {1,2,3,4,5};
|
|
|
|
filterIntArray(heck,5,odd,addOne);
|
|
|
|
for(const auto& val : heck){
|
|
cout << val << endl;
|
|
}
|
|
|
|
return 0;
|
|
}
|