首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
下列给定程序中,函数fun的功能是:依次取出字符串中所有的数字字符,形成新的字符串,并取代原字符串。 请改正函数fun中的错误,使它能得出正确的结果。 注意:不得增行或删行,也不得更改程序的结构! 试题程序: #include <stdlib.h> #in
下列给定程序中,函数fun的功能是:依次取出字符串中所有的数字字符,形成新的字符串,并取代原字符串。 请改正函数fun中的错误,使它能得出正确的结果。 注意:不得增行或删行,也不得更改程序的结构! 试题程序: #include <stdlib.h> #in
admin
2019-04-14
22
问题
下列给定程序中,函数fun的功能是:依次取出字符串中所有的数字字符,形成新的字符串,并取代原字符串。
请改正函数fun中的错误,使它能得出正确的结果。
注意:不得增行或删行,也不得更改程序的结构!
试题程序:
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
void fun(char *s)
{
int i,j;
for(i=0,j=0;s
!=′\0′;i+ +)
if(s
> =′0′&&s
<=′9′)
/* * * * * * found * * * * * */
s[j]=s
;
/* * * * * * found * * * * * */
s[j]=″\0″;
}
void main()
{
char item[80];
system(″CLS″);
printf(″\nEnter a string:″);
gets(item);
printf(″\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/uHf0FFFM
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
有下列程序段:typedefstructNODE{intnum;structNODE*next;}OLD;下列叙述中正确的是()。
以下数组定义中不正确的是______。
以下合法的赋值语句是()
下面程序的输出是【】。main(){intarr[10],i,k=0;for(i=0;i<10;i++)arr[i=i;]for(1;i<4;i
用以下语句调用库函数malloc,使字符指针st指向具有11个字节的动态存储空间,请填空。st=(char*)_________。
设有定义:chars[8];inti=O;,以下不能将—行(不超过80个字符)带有空格的字符串正确读入的语句或语句组是______。
以下叙述中错误的是
以下程序段中与语句k=a>b?(b>c?1:0):0;功能等价的是______。
若要定义一个具有5个元素的整型数组,以下错误的定义语句是()。
以下选项中非法的C语言字符常量是()。
随机试题
下列属于感染因子相关性疾病的是
A、舒喘灵B、喘定C、扑热息痛D、氨哮素E、消炎痛双氯醇胺俗称
上颌第一磨牙髓室底位于颈缘
我国《执业医师法》的实施时间是
在2000版ISO9000族标准中,( )规定了建立质量管理体系的基本要求。
下列人工费用中,不属于预算定额基价构成内容的是()。【2010年真题】
会计工作的社会监督主要是指会计师事务所、税务师事务所、代理记账机构等中介机构对委托单位的经济活动进行审计、鉴证的一种监督制度。( )
报名:考试:揭晓
关于IEEE802标准的描述中,正确的是
A、Thefederalgovernment.B、Students.C、Theschool.D、TheTeachers’Association.A细节题。浏览选项可知,四个选项均是人、集体或组织机构,考查的问题应该与人物有关。原文提到Th
最新回复
(
0
)