首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
下列给定程序中,函数fun的功能是:比较两个字符串,将长的字符串的首地址作为函数值返回。 请改正程序中的错误,使它能得出正确的结果。 注意:部分源程序在文件MODIl,C中,不要改动main函数,不得增行或删行,也不得更改程序的结构!
下列给定程序中,函数fun的功能是:比较两个字符串,将长的字符串的首地址作为函数值返回。 请改正程序中的错误,使它能得出正确的结果。 注意:部分源程序在文件MODIl,C中,不要改动main函数,不得增行或删行,也不得更改程序的结构!
admin
2017-09-23
23
问题
下列给定程序中,函数fun的功能是:比较两个字符串,将长的字符串的首地址作为函数值返回。
请改正程序中的错误,使它能得出正确的结果。
注意:部分源程序在文件MODIl,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 )
{
while ( *tt)
{
t1++;
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 a一
gets (b) ;
printf "\nThe longer is : \n\
}
选项
答案
(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/Ioxp777K
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
下面程序的输出结果是()。#include<stdio.h>main(){intx=7,y=3;printf("%d",y=x/y);}
已知chara;intb;floate;doubled;则表达式a-b+c-d结果为()型。
已知函数isaplha(ch)的功能是判断变量ch是否是字母,若是,则该数值为1,否则为0。下面程序执行后的输出结果是()。#include<ctype.h>#include<string.h>voidfun(cha
运行下列程序时,若输入数据为“321”,则输出结果是()。main(){intnum,i,j,k,s;scanf("%d",&num);if(num>99)s=3;elseif(num>9)
以下程序的功能是进行位运算:main(){unsignedchara,b;a=7^3;b=~4&3;printf("%d%d\n",a,B);}程序运行后的输出结果是()。
数据结构中,与所使用的计算机无关的是数据的()。
以下关于long、int和short类型数据占用内存大小的叙述中正确的是()。
在以下给出的表达式中,与while(E)中的(E)不等价的表达式是()。
在下列模式中,能够给出数据库物理存储结构与物理存取方法的是
已知一个文件中存放若干工人档案记录,其数据结构如下:structa{charnumber[100];intage;floatp[6];};定义一个数组:structanumber[
随机试题
离心式压缩机进气管装导向片来调节流量,其安装位置在()。
人参汤证可以用治胸痹,其药物组成为()
宫颈癌的早期发现与预防措施,不恰当的是
计量检定按其检定的目的和性质,分为首次检定、()。
MACD作为短线买卖指标很灵敏。()
乙公司2019年年末长期资本为5000万元,其中长期银行借款为1000万元,年利率为6%;所有者权益(包括普通股资本和留存收益)为4000万元。公司计划在2020年追加筹集资金5000万元,其中按面值发行债券2000万元,票面年利率为6.86%,期限5年,
一个水箱有1个进水口和10个出水速度相同的出水口,当水箱盛满水后同时打开进水口和10个出水口3小时流完,若打开进水口和5个出水口8小时流完,若打开进水口和8个出水口,水箱的水多少小时流完?()
明朝推行一条鞭法中“一”的内容是()
WhatsuggestiondoesMsLiongivetothestudentsusingInternetasaninformationsource?
Thedevelopmentofinformationtechnologyhasmadetheworldsmaller,andmadepeoplebecomemoreandmoreisolatedfromeachot
最新回复
(
0
)