下面的程序使用了函数指针,其运行结果是______。
#include<stdio.h>#include<math.h>int f1(int a){return a*a;}int f2(int a){return a*a*a;}void main( ){int x=3,y1,y2,y3,y4;f=f1;y1=(*f)(x);y2=f1(x);f=f2;y3=f(x);y4=f2(x);printf("y1=%d,y2=%d,y3=%d,y4=%d\n",y1,y2,y3,y4);}
Ay1=27,y2=9,y3=9,y4=27
By1=9,y2=9,y3=27,y4=27
Cy1=9,y2=27,y3=9,y4=27
Dy1=27,y2=27,y3=9,y4=9
相关试题
-
return a*a*a;}void main( ){int x=3,y1,y2,y3,y4;f=f1;y1=(*f)(x);y2=f1(x);f=f2;y3=f(x);y4=f2(x);printf
-
3,y1,y2,y3,y4;int(*f)( );f=f1;y1=(*f)(x);y2=f1(x);f=f2;y3=f(x);y4=f2(x);printf(“y1=%d,y2=%d,y3=%d,y4
-
printf(%d\n,f1(______)); printf(%d\n,f1(______)); return 0; } int f1(int(*f)(int))
-
); fun(n-2, &f2); *s=f1+f2; } } void main() { int x; fun(6, &x); printf(%d\n, x); } 执行后的输出结果是( )。
-
#include stdio.h int digits(int n) { int c=0; do { c++; n/=10; }while(n);