首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有以下程序 #include int flint n); main(){int a=3,s; int flint n){static int a=1; s=f(a); n+=a++; s=s+f(a);
有以下程序 #include int flint n); main(){int a=3,s; int flint n){static int a=1; s=f(a); n+=a++; s=s+f(a);
admin
2017-05-20
25
问题
有以下程序
#include
int flint n);
main(){int a=3,s; int flint n){static int a=1;
s=f(a); n+=a++;
s=s+f(a); return n;
printf("%d\n",s);} }
程序运行后的输出结果是
选项
A、9
B、8
C、7
D、10
答案
A
解析
在主函数中第一次调用f(a)时,得到变量s的值等于4,在第二次调用f(a)时,在子函数f中由于变量a是一个局部静态变量,所以这次其值等于2,因而在主函数中第二次调用f(a)后,其返回值等于5,最后变量s的值等于9。
转载请注明原文地址:https://kaotiyun.com/show/k4Dp777K
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
设有定义语句int(*f)(int);,则以下叙述正确的是
阅读下面语句,则程序的执行结果是【】。#include"stdio.h"main(){inta=-1,b=1,k;if((++a
以下叙述中错误的是
有以下程序fun(intx){intp;if(x==1)return(3);p=x-fun(x-2);returnp;}main(){printf("%d\n",fun(7));}
下列有关数据库的描述,正确的是
下列叙述中,不属于测试的特征的是
若x和a均是int型变量,则计算完x=(a=4,6*2)后的x值为______。
已定义charch=’$’;inti=1,j;,执行j!=ch&&i++以后,i的值为______。
下列叙述中错误的是
下面关于算法的叙述中,正确的是()。
随机试题
按照视觉的三原色学说,三种视锥细胞特别敏感的颜色是()。
Oneinsix.Believeitornot,that’sthenumberofAmericanswhostrugglewithhunger.Tomaketomorrowalittlebetter,Feedin
A.血尿B.肾小球酸中毒C.白蛋白尿D.白细胞尿E.肾性糖尿糖尿病肾病多表现为
在海拔不超过1000m的地区,在相应风偏条件下,下面带电部分与杆塔构件(包括拉线、铆钉)的最小间隙中()是正确的。
一端固定一端自由的细长(大柔度)压杆,长为L(图a),当杆的长度减小一半时(图b),其临界载荷Fcr比原来增加()。
关于价格总水平影响因素的说法,正确的是()。
有以下程序:#include<stdio.h>main(){inta[10]={1,2,3,4,5,6,7,8,9,10},*p=&a[3],*q=p+2;prinff("%d\n";*p+*q);}
•Readthearticlebelowaboutteam-building.•ChoosethebestwordtofilleachgapfromA,B,CorDontheoppositepage.•For
Thecentralproblemofeconomicsistosatisfythepeople’sandnation’swants.Theproblemwearefacedwithisthatour【C1】___
A、SheiswellpreparedforthisHalloween.B、Shehasn’tgivenmuchthoughttoHalloween.C、ShehascelebratedHalloweenbefore.
最新回复
(
0
)