首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有以下程序 #inclllde int fun(char s[]) main() {int n=0; {char s[10]={’6’,’1’,’*’,’4’,’*’,’9’
有以下程序 #inclllde int fun(char s[]) main() {int n=0; {char s[10]={’6’,’1’,’*’,’4’,’*’,’9’
admin
2019-07-14
24
问题
有以下程序
#inclllde
int fun(char s[]) main()
{int n=0; {char s[10]={’6’,’1’,’*’,’4’,’*’,’9’,’*’,’0’,’*’};
while(*s<=’9’&&*s>=’0’) printf("%d\n",fun(s));
{n=10*n+*s-’0’;s++;} }
return(n);}
程序的运行结果是
选项
A、61490
B、61
C、9
D、5
答案
B
解析
在fun函数中,while循环的功能是逐个取字符数组s的字符判断其是否是数字。若是则将这些数字组成一个数保存到变量n中,并返回变量n的值。所以在主函数中调用fun (s)时,将把字符数组s中的数字组成一个数输出。因为当指针s指向数组的第3位时,即字符件’*’,循环条件不成立,循环结束,返回n的值。所以输出n的值为61。
转载请注明原文地址:https://kaotiyun.com/show/PwRp777K
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
软件测试的目的是
若有定义intx,y;并已正确给变量赋值,则以下选项中与表达式(x-y)?(x++):(y++)中的条件表达式(x-y)等价的是()。
若有以下程序#include#defineS(x)(x)*(x)#defineT(x)S(x)/S(x)+1main(){intk=3,j=2;printf("%d,%d\n",S(k+j),T(k+j));}则程序的输出结果是()
以下叙述中正确的是
有以下程序#includevoidfun(char**p){inti;for(i=0;i<4;i++)printf("%s",p[i]);}main(){char*s[6]={"ABCD","EFGH","IJKL","MNOP","QRST
若变量已正确定义并赋值,以下不能构成C语句的选项是
软件生命周期可分为定义阶段、开发阶段和维护阶段,下面不属于开发阶段任务的是
下面选项中合法的字符常量是
数据字典(DD)所定义的对象都包含于
在数据库系统中,用户所见的数据模式为
随机试题
A、Jobsecurityisthemostimportantfactorofbeinghappy.B、Relationshipwithfamilymembersisatthebottomlistofbeingha
男,18岁,近一年来对家人亲友变得冷淡,不去上学,不洗澡,不主动更换衣服,对与自己有关的各种事情表现得无动于衷。最可能的诊断是
居民消费价格指数是反映()总水平变动的指数。
资产评估的目标是()。
事业单位应当将长期借款的利息记入“其他支出”科目。()
“顷刻间千秋事业,方寸地万里江山;三五步行遍天下,六七人百万雄兵”描写的是:()
Letusassume,forthemoment,thatlabormnotpreparedtoworkforalowermoney-wageandthatareductionintheexistinglev
VeraPerlinBornon28November1902inStJohn’s,Newfoundland,ElizabethVeraCrosbiePerlinisknownforherpioneeringw
WashingtonUniversityinSaintLouis,Missouri,isamedium-sizeduniversity.Ithaseleventhousandstudents.Twelvepercentof
Whatagesisthecomputergamesuitablefor?
最新回复
(
0
)