int add(int a,int b){return a+b;}int sub(int a,int b){return a-b;}if(i%2==0){p=add;}else{p=sub;}int sum=p(3,3);利用了函数指针,赋值不同的函数给它。前提是两个函数的参数要一致