首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
下列给定程序中,函数fun的功能是:依次取出字符串中所有的数字字符,形成新的字符串,并取代原字符串。 请改正函数fun中的错误,使它能得出正确的结果。 注意:不得增行或删行,也不得更改程序的结构! 试题程序: #include #inc
下列给定程序中,函数fun的功能是:依次取出字符串中所有的数字字符,形成新的字符串,并取代原字符串。 请改正函数fun中的错误,使它能得出正确的结果。 注意:不得增行或删行,也不得更改程序的结构! 试题程序: #include #inc
admin
2018-02-02
41
问题
下列给定程序中,函数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://jikaoti.com/ti/1Ka0FFFM
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
有下列程序:#include<stdio.h>main(){charc1,c2,c3,c4,c5,c6;scanf("%c%c%c%c",&c1,&c2,&c3,&c4);c5=getchar();c6=getch
以下能正确定义且赋初值的语句是 ______。
若有定义语句inta,b;doublex;则下列选项中没有错误的是()。
下列叙述中,不属于设计准则的是()。
下列关于栈的叙述中,正确的是
在软件开发过程中,软件结构设计是描述______。
在进行模块测试时,要为每个被测试的模块另外设计两类模块:驱动模块和承接碟块,其中______的作用是将测试数据传送给被测试的模块,并显示被测试模块所产生的结果。
以下四种排序方法中,需要附加的内存空间最大的是______。
随机试题
MydaughterandItooka______touraroundNewYorkCity.
主动关节活动度小于被动关节活动度,提示
患儿,7个月。指纹紫滞。其证候是
竞争成功的关键因素是指影响企业()的能力的主要因素。
土石坝渗流分析主要是确定()。
人事档案利用的方式包括()。
《中华人民共和国合同法》规定,当事人订立合同,应当具有()。
Writeanessayof160~200wordsbasedonthefollowingdrawings.Inyouressay,youshould:1)describethedrawingbriefly;
Bettysaidthat______allherfriends,Marywasherfavorite.
Workshopsonmanagementareheldeveryotherweek_______areexpectedtocontinuethroughouttheyear.
最新回复
(
0
)