首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
下列给定程序中,函数fun的功能是:比较两个字符串,将长的字符串的首地址作为函数值返回。 请改正程序中的错误,使它能得出正确的结果。 注意:部分源程序在文件MODI1.C中,不要改动main函数,不得增行或删行,也不得更改程序的结构! 试题程序: #inc
下列给定程序中,函数fun的功能是:比较两个字符串,将长的字符串的首地址作为函数值返回。 请改正程序中的错误,使它能得出正确的结果。 注意:部分源程序在文件MODI1.C中,不要改动main函数,不得增行或删行,也不得更改程序的结构! 试题程序: #inc
admin
2020-07-28
34
问题
下列给定程序中,函数fun的功能是:比较两个字符串,将长的字符串的首地址作为函数值返回。
请改正程序中的错误,使它能得出正确的结果。
注意:部分源程序在文件MODI1.C中,不要改动main函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#include<conio.h>
#include<stclio.h>
/*********found*********/
double fun(char*s,char*t)
{
int s1=0,t1=0;
char*ss,*tt;
ss=s;
tt=t;
while(*ss)
{
s1++;
/*********found*********/
(*ss)++;
}
while(*tt)
{
t1++;
/*********found*********/
(*tt)++;
}
if(t1>s1)
return t;
else
return s;
}
void main()
{
char a[80],b[80];
printf("\nEnter a string:");
gets(a);
printf("\nEnter a string again:");
gets(b);
printf("\nThe longer is:\n\
n%S\n",fun(a,b));
}
选项
答案
(1)char*fun(char*s,char*t) (2)ss++; (3)tt++;
解析
(1)在主函数的输出语句中,函数fun是以字符串格式输出的,所以定义函数时应为char*fun(char*s,chat*t)。
(2)和(3)这里是地址加1,而不是内容加1,所以改为ss++和tt++。
转载请注明原文地址:https://jikaoti.com/ti/NID0FFFM
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
设有定义:inta=2,b=3,c=4;,则以下选项中值为0的表达式是
设有课程关系模式如下:
有以下程序#include<stdio.h>intflint{inty;if(x==0||x==1)return(3);y=xx-f(x-2);returny:}main(){intz;z=f(3);printf("%d\n",z
以下选项中叙述错误的是
以下叙述正确的是
以下选项中表示一个合法的常量是(说明:符号口表示空格)
设变量均已正确定义并赋值,以下与其他三组输出结果不同的一组语句是
结构化程序所要求的基本结构不包括
设某二叉树的后序序列为CBA,中序序列为ABC,则该二叉树的前序序列为()。
数据库设计中反映用户对数据要求的模式是()。
随机试题
下面各项中属于日耳曼语族的是
以下关于合资有限公司董事会的说法错误的是()
下列选项中,()采取过错责任原则。
环境管理体系二级要素有( )个。
对于一些重要的文件(资料),当发现其被病毒感染时应尽快进行备份。()
在商业银行的合规管理体系中,()制定书面的合规政策,并根据合规风险管理状况以及法律、规则和准则的变化情况适时修订合规政策。
有些白领是喜欢爬山的人。所有的商人都对山区旅游开发项目表示支持。所有喜欢爬山的人都对山区旅游开发项目持反对意见。据此可知()
简述合同无效的情形。
Areyouacompulsivespender,ordoyouholdontoyourmoneyaslongaspossible?Areyouabargainhunter?Wouldyouratherus
Ofalltheareasoflearningthemostimportantisthedevelopmentofattitudes.Emotionalreactionsaswellaslogicalthought
最新回复
(
0
)