首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
下面程序的输出结果是( )。 #include #include using namespace std; class point { private: double x; double
下面程序的输出结果是( )。 #include #include using namespace std; class point { private: double x; double
admin
2021-05-06
26
问题
下面程序的输出结果是( )。
#include
#include
using namespace std;
class point
{
private:
double x;
double y;
public:
point(double a,double b)
{
X=a;
y=b;
}
friend double distances(point a,point b);
};
double distances(point a,point b)
{
return sqrt((a.x-b.x)*(a.x—b.x)+(a.y-b.y)*(a.y-b.y));
}
int main()
{
point p1(1,2);
point p2(5,2);
cout<
return 0;
}
选项
A、2
B、4
C、8
D、16
答案
B
解析
分析题目,此题最终要实现的结果是sqrt((a.x—b.x)*(a.x—b.x)+(a.y—b.y)*(a.y—b.y)),其中的a.x和a.y分别指pl(1,2)中的1和2。这样容易得到结果是(1-5)-(1-5)+(2-2)*(2-2)=16,再开方得到结果为4。
转载请注明原文地址:https://kaotiyun.com/show/cLfp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
使用VC6打开考生文件夹下的源程序文件modi2.cpp。阅读下列函数说明和代码,完成空出部门的程序。实现函数sort(intA[],intn),用冒泡法将数组排序。提示:所谓冒泡法,就是每次把相邻的两个数交换,较大的数交换到后面。这样下标从
下列关于this指针的叙述中,正确的是()。
下列叙述中正确的是
下列关于类模板的模板参数的叙述中,错误的是()。
下列选项中不属于结构化程序设计原则的是()。
有如下语句序列:charstr[10];cin>>str;当从键盘输入“Ilovethisgame”时,str中的字符串是()。
下列有关内联函数的叙述中,正确的是()。
对如下二叉树进行后序遍历的结果为()。
在C++中,实现封装性需借助于()。
随机试题
现存的中国古代第一长桥是()。[2013年福建真题]
有些人的心情比较容易受到外界影响。比如飞行员担心遇到雷暴,虽然没有什么奇招,但有些食物的确能让大脑更好地运作,可可就是其中之一。这是因为可可含有大量的茶碱和咖啡因。它们可以有效地减轻压力和缓解疼痛。以下哪项如果为真,最能支持上述观点:
医学科研的根本价值目标是()
显像剂被脏器或组织摄取的机制与显像方法的关系A.合成代谢B.循环通道C.细胞吞噬D.选择性浓聚E.选择性排泄131I甲状腺显像
男性,65岁。以往血压正常,最近体检发现非同日3次测定血压为180/90mmHg(24/12kPa)。此时应判断为
看涨期权指期权的买方具有在约定期限内(或合约到期日)按()买人一定数量基础金融工具的权利。Ⅰ.协定价格Ⅱ.敲定价格Ⅲ.行权价格Ⅳ.市场价格
下列项目中,应作为城市维护建设税计税依据的有()。
《社会工作专业人才队伍建设中初期规划(2011-2020年)》在《关于加强社会工作专业人才队伍建设的意见》基础之上首次明确了社会工作专业人才队伍包括()3类人才。
以某种教学理论为指导,以一定教学实践为基础形成的,教学活动的各个成分按照一定的要求和程序整合而成的,比较固定的和具有典型性的教学实践形式称之为:
Asitturnedouttobeasmallhouseparty,we________soformally.
最新回复
(
0
)