首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有以下程序 #include<stdio.h> int fun(char s[]) main() {int n=0; {char s[10]={’6’,’1’,’*’,’4’,’*’,’9’,’*’,’0’,’*’}: while(*s<=’9’&&*
有以下程序 #include<stdio.h> int fun(char s[]) main() {int n=0; {char s[10]={’6’,’1’,’*’,’4’,’*’,’9’,’*’,’0’,’*’}: while(*s<=’9’&&*
admin
2016-12-18
26
问题
有以下程序
#include<stdio.h>
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函数中,wbile循环的功能是逐个取字符数组s的字符判断其是否是数字。若是则将这些数字组成一个数保存到变量n中。并返回变量n的值。所以在主函数中调用fun(s)时,将把字符数组s中的数字组成一个数输出。因为当指针s指向数组的第3位时,即字符’*’,循环条件不成立,循环结束,返回n的值。所以输出n的值为61。
转载请注明原文地址:https://kaotiyun.com/show/m8Dp777K
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
若变量已正确定义并赋值,以下符合C语言语法的表达式是
有以下程序:#include<stdio.h>main(){inta=6,b=7,m=1;switch(a%2){case0:m++;bre
结构化分析方法是面向()的自顶向下逐步求精进行需求分析的方法。
仅由顺序、选择(分支)和重复(循环)结构构成的程序是_______程序。
有以下程序#includemain(){ints,t,A=10oubleB=6;s=sizeof(A);t=sizeof(B);printf(”%d,%d\n”,s,t);}在VC6平台
数据库设计中反映用户对数据要求的模式是()。
以下程序中函数fun的功能是:构成一个如图所示的带头结点的单向链表,在结点的数据域中放入了具有两个字符的字符串。函数disp的功能是显示输出该单链表中所有结点中的字符串。请填空完成函数disp。#includetypedefstruc
下列软件系统结构图的宽度为______。
以下程序的功能是建立一个带有头结点的单向链表,链表结点中的数据通过键盘输入,当输入数据为-1时,表示输入结束(链表头结点的data域不放数据,表空的条件是ph->next==NULL),请填空。#includestructlist{intd
软件开发离不开系统环境资源的支持,其中必要的测试数据属于
随机试题
会计工作的组织形式一般有______、______两种。
有关恶性肿瘤细胞的描述不正确的是
婴儿饮食中,三大营养素(蛋白质:脂肪:碳水化合物)所供热量的百分比正确的是
关于受精卵形成的描述,正确的是
考察整个项目的融资前税前现金流量时,其现金流入一般有( )。
关于沥青路面施工用石粉的要求,下列叙述正确的是( )。
企业在固定资产清理过程中,收到应由保险公司或过失人赔偿的损失时,应借记“固定资产清理”。()
机构的职权与职责相平衡是()。
函数f(x)=log0.6(6x-x2)的单调递增区间为().
TherearemanytheoriesaboutthebeginningofdramainancientGreece.Theonemostwidelyacceptedtodayisbasedontheassum
最新回复
(
0
)