1#include #include /*????ص?????*/ int add (int a,int b) { return (a+b); } int sub (int a,int b) { return (a-b); } int mul (int a,int b) { return (a*b); } /*??????á??ص????????ĺ???*/ void math(int (*funcptr)(int x ,int y),int s,int t) { printf("funcptr(int,int)=%d\n",funcptr(s,t)); } int main(void) { int a=22,b=3 ; math(add,a,b); math(sub,a,b); math(mul,a,b); system("pause"); return 0; } /*ָ?뺯??*/ /*int * GetDate(int wk,int dy); int main(void) { int i=0,j=0; for(i=0;i<5;i++) { for(j=0;j<7;j++) printf("%d\t",*GetDate(i,j)); printf("\n"); } system("pause"); return 0; } int * GetDate(int wk,int dy) { int calendar[5][7]= { {1,2,3,4,5,6,7}, {8,9,10,11,12,13,14}, {15,16,17,18,19,20,21}, {22,23,24,25,26,27,28}, {29,30,31,0,0,0,0} }; return &calendar[wk][dy]; } */ /*ʹ?ú???ָ?????鷽ʽ*/ /*typedef int (*funcptr) (int,int); int add (int a,int b) { return (a+b); } int sub (int a,int b) { return (a-b); } int mul (int a,int b) { return (a*b); } int main(void) { int a=30,b=3; funcptr ptr[3]; ptr[0]=add; printf("ptr[0](a,b)=%d\n",ptr[0](a,b)); ptr[1]=sub; printf("ptr[1](a,b)=%d\n",ptr[1](a,b)); ptr[2]=mul; printf("ptr[2](a,b)=%d\n",ptr[2](a,b)); system("pause"); return 0; } */ /*ʹ?ú궨??ķ?ʽ???庯??ָ??*/ /* typedef int (*funcptr) (int,int); int add (int a,int b) { return (a+b); } int sub (int a,int b) { return (a-b); } int mul (int a,int b) { return (a*b); } int main(void) { int a=20,b=3; funcptr ptr; ptr=add; printf("ptr(a,b)=%d\n",ptr(a,b)); ptr=sub; printf("ptr(a,b)=%d\n",ptr(a,b)); ptr=mul; printf("ptr(a,b)=%d\n",ptr(a,b)); system("pause"); return 0; }*/ /*ֱ?Ӷ??庯??ָ??*/ /* int add (int a,int b) { return (a+b); } int sub (int a,int b) { return (a-b); } int mul (int a,int b) { return (a*b); } int main(void) { int a=12,b=3; int (*ptr)(int,int); ptr=add; printf("ptr(a,b)=%d\n",ptr(a,b)); ptr=sub; printf("ptr(a,b)=%d\n",ptr(a,b)); ptr=mul; printf("ptr(a,b)=%d\n",ptr(a,b)); system("pause"); return 0; }*/