#include <stdio.h>
#include <stdlib.h>
int plus ( int a, int b)
{
return a+b;
}
int minus ( int a, int b)
{
return a-b;
}
int m_max ( int a, int b)
{
if (a > b) return a;
return b;
}
int m_min ( int a, int b)
{
if (a < b) return a;
return b;
}
int main(int argc, const char *argv[])
{
void *arr[4] = {plus, minus, m_max, m_min};
int a = 10, b = 5, c, d;
int(*yoba[])(int, int) = {m_min, m_max};
printf ("m_min(%i %i) = %i \n", a, b, yoba[0](a,b) );
printf ("m_max(%i %i) = %i \n", a, b, yoba[1](a,b) );
c = ( (int(*)(int, int)) arr[0] )(a, b);
d = ( (int(*)(int, int)) arr[1] )(a, b);
printf ("%i + %i = %i\n", a
, b
, c
); printf ("%i - %i = %i\n", a
, b
, d
); return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KCmludCBwbHVzICggaW50IGEsIGludCBiKQp7CiAgICByZXR1cm4gYStiOwp9CgppbnQgbWludXMgKCBpbnQgYSwgaW50IGIpCnsKICAgIHJldHVybiBhLWI7Cn0KCmludCBtX21heCAoIGludCBhLCBpbnQgYikKewogICAgaWYgKGEgPiBiKSByZXR1cm4gYTsKICAgIHJldHVybiBiOwp9CgppbnQgbV9taW4gKCBpbnQgYSwgaW50IGIpCnsKICAgIGlmIChhIDwgYikgcmV0dXJuIGE7CiAgICByZXR1cm4gYjsKfQoKCgppbnQgbWFpbihpbnQgYXJnYywgY29uc3QgY2hhciAqYXJndltdKQp7CiAgICB2b2lkICphcnJbNF0gPSB7cGx1cywgbWludXMsIG1fbWF4LCBtX21pbn07CiAgICBpbnQgYSA9IDEwLCBiID0gNSwgYywgZDsKCiAgICBpbnQoKnlvYmFbXSkoaW50LCBpbnQpID0ge21fbWluLCBtX21heH07CiAgICBwcmludGYgKCJtX21pbiglaSAlaSkgPSAlaSBcbiIsCiAgICAgICAgICAgICAgICAgICBhLCBiLCAgICB5b2JhWzBdKGEsYikgKTsKICAgIHByaW50ZiAoIm1fbWF4KCVpICVpKSA9ICVpIFxuIiwKICAgICAgICAgICAgICAgICAgIGEsIGIsICAgIHlvYmFbMV0oYSxiKSApOwoKCiAgICBjID0gKCAoaW50KCopKGludCwgaW50KSkgYXJyWzBdICkoYSwgYik7CiAgICBkID0gKCAoaW50KCopKGludCwgaW50KSkgYXJyWzFdICkoYSwgYik7CiAgICBwcmludGYgKCIlaSArICVpID0gJWlcbiIsIGEsIGIsIGMpOwogICAgcHJpbnRmICgiJWkgLSAlaSA9ICVpXG4iLCBhLCBiLCBkKTsKICAgIHJldHVybiAwOwp9