首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
下列给定程序中,函数fun的功能是:依次取出字符串中所有的数字字符,形成新的字符串,并取代原字符串。 请改正函数fun中的错误,使它能得出正确的结果。 注意:不得增行或删行,也不得更改程序的结构! 试题程序: #include <stdlib.h> #in
下列给定程序中,函数fun的功能是:依次取出字符串中所有的数字字符,形成新的字符串,并取代原字符串。 请改正函数fun中的错误,使它能得出正确的结果。 注意:不得增行或删行,也不得更改程序的结构! 试题程序: #include <stdlib.h> #in
admin
2019-04-14
17
问题
下列给定程序中,函数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://kaotiyun.com/show/e9Rp777K
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
以下选项中的表达式调用库函数依次求-4.5的绝对值、-4.0的平方根值、30°角的正弦值和2的3次方值。正确的调用是()
若有以下定义和语句:inta[]={1,2,3,4,5,6,7,8,9,10},*p=a;则值为3的表达式是______。
设a=2、b=3、c=4,则表达式a+b>c&&b==c&&a||b+c&&b+c的值为______。
在C语言程序中,下列说法正确的是()。
若有说明chars1[]="Thatgirl",s2[]="isbeautiful";则使用函数strcmp(s1,s2)后,结果是______。
以下程序中,fun函数的功能是求3行4列二维数组每行元素中的最大值。请填空。voidfun(int,int,int(*)[4],int*);main(){inta[3][4]={{12,41,36,28},{19,33,1
下面的叙述正确的是()。
对于n个结点的单向链表(无表头结点),需要指针单元的个数至少为______。
C语言程序的模块化是通过以下哪个选项实现的()。
深度为7的二叉树共有127个结点,则下列说法中错误的是()。
随机试题
下列文章中,体现民本思想的是()
悲剧作为审美形态,与其发展紧密相关的西方艺术形式是()
______,liquidscanbechangedintogases.
2007年8月,神州塑料制品股份有限公司就公司某些主要职务的任职人选作出以下决议,其中哪些不符合法律规定?()
甲为出售一台挖掘机分别与乙、丙、丁、戊签订买卖合同,具体情形如下:2016年3月1日,甲胁迫乙订立合同,约定货到付款;4月1日,甲与丙签订合同,丙支付20%的货款;5月1日,甲与丁签订合同,丁支付全部货款;6月1日,甲与戊签订合同,甲将挖掘机交付给戊。上述
预应力筋切断不得采用()切割。
现行合同法采取的违约责任归责原则是()。
销毁国家秘密文件,应当到()。
Readthetextbelowabouttheuseofpaperinoffices.Inmostofthelines(34-45),thereisoneextraword.Iteitherisgramma
Wedidn’tfinishtheworkintime.You______ussinceyouwerethere.
最新回复
(
0
)