/****************************/ /* 関数(関数名) */ /* coded by Y.Suganuma */ /****************************/ #include <stdio.h> int add(int s1, int s2) { int s = s1 + s2; return s; } int sub(int s1, int s2) { int s = s1 - s2; return s; } int add_sub(int (*fun)(int, int), int s1, int s2) { int s = fun(s1, s2); return s; } int main() { printf("%d\n", add(2, 3)); // 5 int (*kasan)(int, int) = &add; printf("%d\n", kasan(2, 3)); // 5 printf("%d\n", add_sub(add, 2, 3)); // 5 printf("%d\n", add_sub(sub, 2, 3)); // -1 return 0; }