有以下程序 #include <stdio.h> int f( int x[], int n ) { if ( n> 1) return x[n-1]+ f(x, n-1)*10; else return x

admin2020-06-16  12

问题 有以下程序
#include   <stdio.h>
int  f( int  x[], int  n )
{  if ( n> 1)
      return  x[n-1]+ f(x, n-1)*10;
   else
      return  x[0];
}
main( )
{  int  z[3] = {1,2,3}, y;
   y = f(z,3);
   printf( "%d\n", y );
}
程序运行后的输出结果是

选项 A、321
B、123
C、1
D、3

答案B

解析 f函数的作用是将int型数组构造成一个整型数。f函数采用递归的方式来实现,位数是递增的。有题设可知结果为123,因此输出结果为B选项
转载请注明原文地址:https://kaotiyun.com/show/Ss3p777K
0

最新回复(0)