首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有以下程序 #include<stdio.h> int fun(char s[]) main() {int n==0; {char s[10]={’6’
有以下程序 #include<stdio.h> int fun(char s[]) main() {int n==0; {char s[10]={’6’
admin
2020-05-19
17
问题
有以下程序
#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函数中,while循环的功能是逐个取字符数组s的字符判断其是否是数字。若是则将这些数字组成一个数保存到变量n中,并返回变量n的值。所以在主函数中调用fun(s)时,将把字符数组s中的数字组成一个数输出。因为当指针s指向数组的第3位时,即字符’*’,循环条件不成立,循环结束,返回n的值。所以输出n的值为61。
转载请注明原文地址:https://kaotiyun.com/show/QgCp777K
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
有以下程序:#includemain(){intx[3][2]={0},i;for(i=0;i
设有如下函数定义:#includeintfun(intk){if(k
下列叙述中正确的是()。
以下选项中,不合法的C语言用户标识符是()。
有以下程序:#includemain(){inti,j,m=55;for(i=1;i
给定程序中,函数fun的功能是:有N×N矩阵,根据给定的m(m
设有定义:char*c:,以下选项中能够使字符型指针c正确指向一个字符串的是()。
以下选项中与if(a=1)a++;elsea=b;语句功能不同的语句是()。
人员的记录由编号和出生年、月、日组成,N名人员的数据已在主函数中存入结构体数组std中。函数fun的功能是:找出指定出生年份的人员,将其数据放在形参k所指的数组中,由主函数输出,同时由函数值返回满足指定条件的人数。请在程序的下划线处填入正确的内容
学生的记录由学号和成绩组成,N名学生的数据已在主函数中放入结构体数组s中,请编写函数fun,它的功能是:函数返回指定学号的学生数据,指定的学号在主函数中输入。若没找到指定学号,在结构体变量中给学号置空串,给成绩置-1,作为函数值返回。(用于字符串比较的函数
随机试题
下图所示为()。
属于骨折功能复位的是
女性,30岁。喘息、呼吸困难发作1天,过去有类似发作史。体检:气促、发绀,双肺满布哮鸣音,心率120次/分,律齐,无杂音。院外已用过氨茶碱、特布他林无效。对该患者除立即吸氧外,应首先给予的治疗措施为
45岁女性,严重骨盆骨折,24小时尿量200ml,血钾5.9mmol/L,二氧化碳结合力13mmol/L,血尿素氮27mmol/L,下列治疗措施不正确的是
检验批是指按同一的生产条件或按规定的方式汇总起来供检验用的,由一定数量()组成的检验体。
下列有关设备报废的论述中正确的是()。
跟踪误差越大,调整所花费的交易成本越低。()
根据票据法律制度的规定,下列有关汇票出票人记载事项的表述中,可以导致票据无效的有()
选择玩具的基本准则:不是玩具本身能干些什么,而是儿童使用玩具能做些什么。()
Thereissomedoubt______Johnwillcomeontime.
最新回复
(
0
)