首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有以下程序 #include void fun ( int n ,int *s ) { int f; if( n==1 ) *s = n+1 ; else { fun( n-1, &f) ; *s = f ; } } main() { int
有以下程序 #include void fun ( int n ,int *s ) { int f; if( n==1 ) *s = n+1 ; else { fun( n-1, &f) ; *s = f ; } } main() { int
admin
2015-07-31
47
问题
有以下程序
#include
void fun ( int n ,int *s )
{
int f;
if( n==1 ) *s = n+1 ;
else
{
fun( n-1, &f) ;
*s = f ;
}
}
main()
{
int x =0;
fun( 4,&x );
printf("%d\n",x);
}
程序运行后的输出结果是
选项
A、3
B、1
C、2
D、4
答案
C
解析
本题考查函数的递归调用,将函数参数带入函数中,一步步递归即可得到结果,结果为2,选项C正确。
转载请注明原文地址:https://kaotiyun.com/show/X2Dp777K
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
下列程序的输出结果是【】。main(){inta[]={2,4,6},*ptr=&a[0],x=8,y,z;for(y=0;y<3;y++)z=(*(ptr+y)<x)?*(ptr+y):x;p
以下程序运行后的输出结果是【】。#include<stringh>voidfun(char*s,intp,intk){inti;for(i=p;i<k-1;i++)s[i]=s[i+2];}
下列程序段的执行结果是______。inti;intx[][3]=}1,2,3,4,5,6,7,8,9};for(i=0;i<3;i++)printf("%d",x[i][2-i]);
分析下列程序,其最终执行结果是______。main(){intn[3],i,j,k;for(i=0;i<3;i++)n[i]=O;k=2;for(i=0;i<k;i++)f
以下叙述中正确的是______。
下列循环的循环次数是______。ihtk=2;while(k=0)printf("%d",k);k--;printf("\n");
算法的复杂度主要包括时间复杂度和______复杂度。
两个或两个以上模块之间联系的紧密程度称为()
在面向对象方法中,类之间共享属性和方法的机制称为______。
一个教师可讲授多门课程,一门课程可由多个教师讲授。则实体教师和课程间的联系是
随机试题
毛泽东在探索中国社会主义建设道路过程中提出,社会主义的发展阶段可能分为()
建筑石膏的特性包括()。
监理单位对其验收合格项目的施工质量负()。
金砖四国
目前主要的运营网络有电信网、______和计算机网。
Ifyouintendusinghumorinyourtalktomakepeoplesmile,youmustknowhowtoidentifysharedexperiencesandproblems.Your
In1919Britainexperienceditslargesteverreductioninindustrialworkinghours,to48perweek.InDowie’sviewthe48-hour
1 Peoplehavebeenpaintingpicturesforatleast30,000years.Theearliestpictureswerepaintedbypeoplewhohuntedanimals
It’snouse_______menottoworry.
Underproperconditions,soundwaveswillbereflectedfromahillsideorothersuchobstruction.Soundtravelsattherateofa
最新回复
(
0
)