首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
下述语句中,在字符串s1和s2相等时显示“they are Equal”的是( )。
下述语句中,在字符串s1和s2相等时显示“they are Equal”的是( )。
admin
2019-08-18
25
问题
下述语句中,在字符串s1和s2相等时显示“they
are Equal”的是( )。
选项
A、if(*s1=*s2)
puts("they are Equal");
B、if(!strcmp(s1,s2))
puts("they are Equal");
C、if(s1=s2)
Puts("they are Equal");
D、if(strcmp(s1,s2))
puts("they are Equal");
答案
B
解析
字符串比较不能用两个等号(==)来进行比较,应使用“strcmp(s1,s2)”函数来比较。“strcmp(s1,s2)”函数的功能是:当字符串s1和s2相等时,返回值为0,因此,当表达式“!strcmp(s1,s2)=1”时,条件成立,执行后面的语句,输出“they are Equal”。
转载请注明原文地址:https://kaotiyun.com/show/xpRp777K
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
请编写函数fun,其功能是:将一个数字字符串转换为一个整数(不得调用C语言提供的将字符串转换为整数的函数)。例如,若输入字符串“一1234”,则函数把它转换为整数值一1234。注意:部分源程序给出如下。请勿改动主函数main和其他函数中
下列给定程序中,函数fun和funx的功能是:用二分法求方程2x<sup>3一4x<sup>2+3x一6=0的一个根,并要求绝对误差不超过0.001。例如,若给m输入一100,给n输入90,则函数求得的一个根为2.000。请改正程序中的错误
给定程序中,函数fun的功能是:有N×N矩阵,以主对角线为对称线,对称元素相加并将结果存放在左下三角元素中,右上三角元素置为0。例如,若N=3,有下列矩阵:123456789计算结
给定程序中,函数fun的功能是:有N×N矩阵,将矩.阵的外围元素顺时针旋转。操作顺序是:首先将第一行元素的值存入临时数组r,然后使第一列成为第一行,最后一行成为第一列,最后一列成为最后一行,临时数组中的元素成为最后一列。例如,若N=3,有下列矩阵
请编写函数fun,函数的功能是:统计一行字符串中单词的个数,作为函数值返回。一行字符串在主函数中输入,规定所有单词由小写字母组成,单词之间由若干个空格隔开,一行的开始没有空格。注意:部分源程序在文件PROG1.C中。请勿改动主函数mai
给定程序中,函数fun的功能是将不带头节点的单向链表结点数据域中的数据从小到大排序。即若原链表结点数据域从头至尾的数据为:10、4、2、8、6,排序后链表结点数据域从头至尾的数据为:2、4、6、8、10。请在程序的下划线处填入正确的内容并把下划线
下列定义数组的语句中,正确的是
设有定义:charp[]={’1’,’2’,’3’),*q=p;以下不能计算出一个char型数据所占字节数的表达式是
数据库系统的三级模式不包括
随机试题
下列属于社会工作者解救危难的案例的是()。
关于实性癌的叙述,下列哪项是错误的()
血管外破坏红细胞的主要场所是()。
依据《中华人民共和国循环经济促进法》,新建、改建、扩建建设项目,必须符合本行政区域()的要求。
某工程项目由于发包人拖延支付工程款而导致长期停工,施工方只好将设备撤场,作业人员同时也转场施工,此时施工现场的安全防护应由()负责。
统计执法检查机构的主要职责有()。
一些中学生在做作业的时候喜欢封闭安静的环境,不喜欢有他人在场,更不喜欢他人干预自己的作业进展情况。他们所具有的认知方式为()。
甲听说乙有一祖传玉石,遂前往询价,甲问:你多少钱卖?乙说:你出多少钱?甲问:15万元卖不卖?乙说:20万元可以马上拿走。甲未置可否。三天后,甲携款20万元前来购买,乙说:25万元才能卖。对此,下列选项正确的是()。
下列行为中,成立重婚罪的是()
在使用项目管理器时,选择移去文件,然后在提示的框中选择“移去”命令按钮,系统将会把该文件()。
最新回复
(
0
)