首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
下面程序的输出结果是( )。 #include #include using namespace std; class point { private: double x: double y;
下面程序的输出结果是( )。 #include #include using namespace std; class point { private: double x: double y;
admin
2021-09-05
33
问题
下面程序的输出结果是( )。
#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<
retum 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/H65p777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
有如下程序:#include#includeusingnsmespacestd;classPerson{public:Person(stringn):name(n){cout
下面程序中对一维坐标点类Point进行运算符重载#include<iostream>usingnamespacestd;classPoint{public:Point(intval){x=val;}
下列关于运算符重载的叙述中,正确的是()。
若需要为XV类重载乘法运算符,运算结果为XV类型,在将其声明为类的成员函数时,下列原型声明正确的是()。
在数据管理技术发展的三个阶段中,数据共享最好的是()。
要定义一个引用变量p,使之引用类MyClass的一个对象,正确的定义语句是.()。
下面是重载为非成员函数的运算符的函数原型,其中错误的是()。
下列运算符函数中,肯定不属于类Value的成员函数的是()。
下列选项中属于面向对象设计方法主要特征的是()。
请使用菜单命令或直接用VC6打开考生文件夹下的工程proj2,其中有元素类Element和集合类MySet的定义。请在程序中的横线处填写适当的代码,然后删除横线,以实现上述类定义。此程序的输出结果应为:0358038
随机试题
某井使用CYJ5—2.1—13HB型抽油机,泵挂深度=1000mm,连杆长度L=1800mm,曲柄半径r=495mm,冲程S=1.4m,冲数n=9次/min,抽油杆柱在空气中的重力Wr=23800N,在相对密度=0.933的液体中的重力W’r=21000N
导体对电流的阻碍作用称为电阻。
A.减少房水生成B.睫状肌痉挛C.减慢心率D.增加房水排出E.浓缩玻璃体高渗药的作用机制是
首选方是:若伴见倦怠乏力,气短懒言,心悸少寐。方选:
肾盂肾炎的主要感染途径为
关于刑事诉讼价值的理解,下列哪一选项是错误的?(2015年卷二22题)
下列人员中,可以担任破产案件中的管理人的是()。
根据下面材料回答问题。下列哪类人员2009年网民人数比上年有所减少?
$10,000
Mywifeisoutofworknow,sowehaveto______ourlivingexpenses.
最新回复
(
0
)