首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
下列给定程序中,函数fun的功能是:依次取出字符串中所有的数字字符,形成新的字符串,并取代原字符串。 请改正函数fun中的错误,使它能得出正确的结果。 注意:不得增行或删行,也不得更改程序的结构! 试题程序: #include #inc
下列给定程序中,函数fun的功能是:依次取出字符串中所有的数字字符,形成新的字符串,并取代原字符串。 请改正函数fun中的错误,使它能得出正确的结果。 注意:不得增行或删行,也不得更改程序的结构! 试题程序: #include #inc
admin
2018-02-02
34
问题
下列给定程序中,函数fun的功能是:依次取出字符串中所有的数字字符,形成新的字符串,并取代原字符串。
请改正函数fun中的错误,使它能得出正确的结果。
注意:不得增行或删行,也不得更改程序的结构!
试题程序:
#include
#include
#include
void fun(char*s)
{
int i,j;
for(i=0,j=0;s
1=‘\0’;i++)
if(s
>=‘0’&&s
<=‘9’)
/*******found*******/
s[j]=s
;
/*******found*******/
s[j]=“\0”;
}
void main()
{
char item[80];
system(“CLS”);
prinff(“\nEnter a string:”);
gets(item);
prinff(“\nThe string is:%s\n”,item);
fun(item);
printf(“\nThe string of changing is:%s\n”,
item);
}
选项
答案
(1)s[j++]=s[i]; (2)s[j]=’\0’;
解析
题目要求依次取出字符串中所有的数字字符,因此将元素s
存入s[j]后要使j加1,为下次存储做准备。s[j]=“\0”;是一个语法错误。
转载请注明原文地址:https://kaotiyun.com/show/MXxp777K
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
有以下程序:#includemain(){chara[5][10]={"one","two","three","four","five"}:inti,j;chart;for(i=0;i<4;i++)for(
为了建立如图所示的存储结构(即每个结点含两个域,data是数据域,next是指向结点的指针域)。请填空。structlink{chardata;【】;}node;
下列程序的运行结果是______。#definePOWER(x)((x)*(x))main(){inti=1;printf("%d,%d",POWER(i++),i);}
一个模块直接调用的其他模块的模块个数称为______。
下列选项中不合法的十六进制数是()。
有以下结构体说明和变量定义,如图所示,指针p、q、r分别指向一个链表中的三个连续结点。 struct node { int data; struct node*next; }*p,*q,*r; 现要将q和r所指结点的先后位置交换,同时要保持链表的连续,
以下关于结构化程序设计的叙述中正确的是()。
在进行模块测试时,要为每个被测试的模块另外设计两类模块:驱动模块和承接碟块,其中______的作用是将测试数据传送给被测试的模块,并显示被测试模块所产生的结果。
下列选项中,不是一个算法的基本特征的是()。
下列叙述中,正确的是
随机试题
甲在建筑工地开翻斗车。某夜,甲开车时未注意路况,当场将工友乙撞死、丙撞伤。甲背丙去医院,想到会坐牢,遂将丙弃至路沟后逃跑。丙不得救治而亡。关于本案,下列哪一选项是错误的?()(2013/2/12)
女,46岁,糖尿病史3年,经饮食治疗并服二甲双胍,病情控制良好。近日受凉后发热,咳嗽,咳黄痰,X线检查为右下肺炎。血糖18.6mmol/L,尿糖++++。对该患者除治疗肺炎外,糖尿病的处理应
肛周脓肿自行破溃后形成
采用项目式组织方式进行多个项目管理的缺点是()。
根据《刑法》规定,无期徒刑减为有期徒刑时,附加剥夺政治权利的期限应当改为( )。
下列关于影响资本结构的说法中,不正确的是()。
在我国整个法律监督体系中居于主导地位的是:
今后我国农业和农村工作的出发点和落脚点是()。
Investorsunanimouslyvotedinfavorofthe______merger.
Man:Mybrotheriscomingthisweekend,andIwasthinkingthethreeofuscouldgoouttodinnerSaturdaynight.Anysuggestion
最新回复
(
0
)