首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有以下程序 #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
47
问题
有以下程序
#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全国计算机二级
相关试题推荐
下列程序的输出结果是【】。main(){inti;for(i=1;i+1;i++){if(i>4){printf("%d\n",i);break;}printf("%d\n",i++);}}
以下程序的输出结果是【】。main(){charc=′z′;printf("%c",c-25);}
有下面程序段#include"stdio.h"#include"string.h"main(){chara[3][20]={{"china"},{"isa"},{"bigcountry!"}};chark[100]={0},
若有定义:char*st="howareyou";,下列程序段中正确的是
下面关于对象概念的描述中,错误的是
以下scanf函数调用语句中对结构体变量成员的引用不正确的是{charname[20];}pup[5],*p;
下面能正确进行字符串赋值操作的是
有以下程序intadd(inta,intb){return(a+b);}main(){intk,(*f)(),a=5,b=10;f=add;}则以下函数调用语句错误的是
下述关于数据库系统的叙述中正确的是
随机试题
衡量数据传输有效性的主要指标是()率。
A、Adrugstore.B、Thenameofhighbuilding.C、Asupermarket.D、Thenameofastreet.A
"TheHeartoftheMatter",thejust-releasedreportbytheAmericanAcademyofArtsandSciences(AAAS),deservespraiseforaff
来源于菊科的药材有
与CHP对工作服的规定不符合的是
当计划工期等于计算工期时,()就是关键工作。
我国古代科举考试殿试中,“一甲”3名称为“赐进士出身”。()
下列词语中,没有错别字的一项是()。
ManypeopleinvestinthestockmarkethopingtofindthenextMicrosoftandDell.However,Iknowfrompersonalexperiencehow
Itmaybeinferredfromthepassagethat______.Intheauthor’sview,higherservicestandardsareimpossibleinIsrael______
最新回复
(
0
)