Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdbool.h>
- #include <stdlib.h>
- void printOk(int arr[], int n, bool (*f)(int)) {
- for (int i = 0; i < n; i++) {
- if (f(arr[i])) {
- printf("%d: %d\n", i, arr[i]);
- }
- }
- }
- bool isOdd(int x) {
- return x & 1;
- }
- int main(void) {
- int n;
- scanf("%d", &n);
- int *arr = calloc(sizeof(int), n);
- for (int i = 0; i < n; i++) {
- scanf("%d", arr + i);
- }
- printOk(arr, n, isOdd);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement