20 lines
364 B
C
20 lines
364 B
C
|
#include <stdio.h>
|
||
|
int increment(int x)
|
||
|
{
|
||
|
return x + 1;
|
||
|
}
|
||
|
|
||
|
int map(int* arr, int len, int (*func)(int))
|
||
|
{
|
||
|
for (int i = 0; i < len; i++)
|
||
|
arr[i] = func(arr[i]);
|
||
|
}
|
||
|
int main(int argc, const char *argv[])
|
||
|
{
|
||
|
int nums[7] = {1, 2, 3, 4, 5, 6, 7};
|
||
|
map(nums, 7, &increment);
|
||
|
for (int i = 0; i < 7; i++) {
|
||
|
printf("%d\n", nums[i]);
|
||
|
}
|
||
|
}
|