首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
使用VC++2010打开考生文件夹下modi1中的解决方案。此解决方案的项目中包含一个源程序文件modi1.c。在此程序中,函数fun的功能是:比较两个字符串,将长的字符串的首地址作为函数值返回。 请改正程序中的错误,使它能得出正确的结果。 注意:部分源程
使用VC++2010打开考生文件夹下modi1中的解决方案。此解决方案的项目中包含一个源程序文件modi1.c。在此程序中,函数fun的功能是:比较两个字符串,将长的字符串的首地址作为函数值返回。 请改正程序中的错误,使它能得出正确的结果。 注意:部分源程
admin
2020-01-10
23
问题
使用VC++2010打开考生文件夹下modi1中的解决方案。此解决方案的项目中包含一个源程序文件modi1.c。在此程序中,函数fun的功能是:比较两个字符串,将长的字符串的首地址作为函数值返回。
请改正程序中的错误,使它能得出正确的结果。
注意:部分源程序在文件MODI1.C中,不要改动main函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#include<conio.h>
#include<stdio.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,char*t)。
(2)和(3)这里是地址加1,而不是内容加1,所以改为ss++和tt++。
转载请注明原文地址:https://kaotiyun.com/show/BFCp777K
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
有以下程序voidswap(char*x,char*y){chart;t=*x;*x=*y;*y=t;}main(){char,*s1="abc",*s2="123";
若有以下程序#includeint*f(int*s,int*t){intk;if(*s<*t){k=*s;*s=*t;*t=k;}returns;)
有以下程序fun(intx){intp;if(x==0‖x==1)return(3);p=x-fun(x-2);returnp;}main(){printf("%d
有以下程序#includemain(){intb[3][3]={0,1,2,0,1,2,0,1,2},i,j,t=1;for(i=0;i
设有定义:intx=2;以下表达式中,值不为6的是
若有以下程序main(){inta=-2,b=0;while(a++)++b;printf("%d,%d\n",a,b);)则程序的输出结果是
请编写函数fun,其功能是:判断t所指字符串中的字母是否由连续递增字母序列组成(字符串长度大于等于2)。例如字符串:uvwxyz满足要求;而字符串:uvxwyz不满足要求。注意:部分源程序存放在PROG1.C中,请勿改动主函数main和其他函数中的任何内
设二叉树的前序序列与中序序列均为ABCDEFGH,则该二叉树的后序序列为
下面属于黑盒测试方法的是()。
设有栈S和队列Q,初始状态均为空。首先依次将A,B,C,D,E,F入栈,然后从栈中退出三个元素依次入队,再将X,Y,Z入栈后,将栈中所有元素退出并依次入队,最后将队列中所有元素退出,则退队元素的顺序为()。
随机试题
当吸收剂需循环使用时,吸收塔的吸收剂入口条件将受到解吸操作条件的制约。()
股票发行环节最重要的信息披露文件是()
下列级数收敛的是()
具有子宫颈枕的家畜是
理气解郁法治疗瘿病的代表方剂是()
原属于农民集体所有,但后来在事实上转归国有单位、城市集体所有制单位或其他非农民经济组织的土地,按照1995年原国家土地管理局《确定土地所有权和使用权的若干规定》的有关规定,确定为()所有。
有人说:“在第二次鸦片战争中,俄国不需花费一文一钱,不必动用一兵一卒,而能比任何一个国家得到更多的好处。”这里“更多的好处”指()。
我国诚信日为()。
写出快速排序的非递归算法。
设其中g(x)是有界函数,则f(x)在x=0处
最新回复
(
0
)