#include <stdio.h>
#define FUNC(N) void f##N(void) {printf("from %d\n",N);}
#define f(N) f##N()
// 定義 function
FUNC(0) FUNC(1) FUNC(2) FUNC(3) FUNC(4) FUNC(5) FUNC(6) FUNC(7)
FUNC(8) FUNC(9) FUNC(10) FUNC(11) FUNC(12) FUNC(13) FUNC(14) FUNC(15)
int main()
{
char input[1000];
typedef void (*fptr)(void);
fptr exe_fun[]={f0,f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15};
printf("input binary code (4bits):"); while(scanf("%s", input
)==1){ unsigned dec =
(((input[3]=='1') << 0) |
((input[2]=='1') << 1) |
((input[1]=='1') << 2) |
((input[0]=='1') << 3) );
exe_fun[dec]();
printf("input binary code (4bits):"); }
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgojZGVmaW5lIEZVTkMoTikgdm9pZCBmIyNOKHZvaWQpIHtwcmludGYoImZyb20gJWRcbiIsTik7fQojZGVmaW5lIGYoTikgZiMjTigpCi8vIOWumue+qSBmdW5jdGlvbgpGVU5DKDApIEZVTkMoMSkgRlVOQygyKSBGVU5DKDMpIEZVTkMoNCkgRlVOQyg1KSBGVU5DKDYpIEZVTkMoNykgCkZVTkMoOCkgRlVOQyg5KSBGVU5DKDEwKSBGVU5DKDExKSBGVU5DKDEyKSBGVU5DKDEzKSBGVU5DKDE0KSBGVU5DKDE1KSAKaW50IG1haW4oKQp7CgljaGFyIGlucHV0WzEwMDBdOwoJdHlwZWRlZiB2b2lkICgqZnB0cikodm9pZCk7CglmcHRyIGV4ZV9mdW5bXT17ZjAsZjEsZjIsZjMsZjQsZjUsZjYsZjcsZjgsZjksZjEwLGYxMSxmMTIsZjEzLGYxNCxmMTV9OwoJCglwcmludGYoImlucHV0IGJpbmFyeSBjb2RlICg0Yml0cyk6Iik7Cgl3aGlsZShzY2FuZigiJXMiLCBpbnB1dCk9PTEpewoJCXVuc2lnbmVkIGRlYyA9IAoJCQkoKChpbnB1dFszXT09JzEnKSA8PCAwKSB8IAoJCQkgKChpbnB1dFsyXT09JzEnKSA8PCAxKSB8IAoJCQkgKChpbnB1dFsxXT09JzEnKSA8PCAyKSB8CgkJCSAoKGlucHV0WzBdPT0nMScpIDw8IDMpICk7CgkJCQkKCQlleGVfZnVuW2RlY10oKTsKCQlwcmludGYoImlucHV0IGJpbmFyeSBjb2RlICg0Yml0cyk6Iik7Cgl9CglyZXR1cm4gMDsKfQ==