首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
下面程序的输出结果是( )。 #include #inc!ude using namespace std; class point { private: doubl
下面程序的输出结果是( )。 #include #inc!ude using namespace std; class point { private: doubl
admin
2012-12-29
20
问题
下面程序的输出结果是( )。
#include
#inc!ude
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分别指p1(1,2冲的1和2。这样容易得到结果是(1-5)*(1-5)+(2-2)*(2-2)=16,再开方得到结果为4。
转载请注明原文地址:https://jikaoti.com/ti/qcL0FFFM
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
若有定义语句:doublea,*p=&a;以下叙述中错误的是
有以下程序:#include<stdio.h>main(){intx=0xg;pfinff("%c\n",’A’+x);}程序运行后的输出结果是()。
已知一个文件中存放若干工人档案记录,其数据结构如下:structa{charnumber[100];intage;floatp[6];};定义一个数组:structab[10];
下列叙述中错误的是()。
我们所写的每条C语句,经过编译最终都将转换成二进制的机器指令。关于转换以下说法错误的是
以下叙述中错误的是()。
下列各项中不合法的常量是()。
关系数据库管理系统能实现的专门关系运算包括()。
在关系代数运算中,有5种基本运算,它们是()。
下列算法中均以比较作为基本运算,则平均情况与最坏情况下的时间复杂度相同的是()。
随机试题
—Iheardthatsomepolicedidn’tallowsuspectsenoughsleeptogetso-calledcriminalevidenceinAmerica.—______?Thiscert
A.门静脉海绵样变B.巴德一吉亚利综合征C.肝包虫病D.血吸虫病E.原发性肝癌属于肝前型门脉高压症的疾病是
类风湿关节炎的主要表现是
支配虹膜环形肌的是()
下列说法错误的是:()
我国发行的债券目前主要偿还方式是采用( )。
以下是某求助者与咨询师的谈话,请据此回答问题:心理咨询师:你最近有什么烦心的事情吗?想和我交流一下吗?我是一个职业的心理咨询师,我会为我们今天的谈话保密的。求助者:最近一个月一直心情低落,上班时无精打采的,也不想和同事们来往,厌食,失眠
()不是人力资源开发目标的特性。
传统节日有了法定假期,未必就不会渐行渐远。一个古老节日之所以沿袭不衰,真正动因不在于它有多热闹、能带来多少商机,而在于它承载着中国人代代积累下来的那份感情,流淌着中华民族赖以生存繁衍的精神血脉和文化基因。如今社会进步,经济发展,人们对传统节日有了更高的要求
毛泽东提出的具有中国特点的民主革命道路理论初步形成的标志是
最新回复
(
0
)