问答题使用VC6打开
下的源程序文件modi3.cpp。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。完成以下功能:
(1)完成类Rect的构造函数,实现对变量left、right、top、bottom的初始化,缺省值都为0,请在注释//********1********后添加适当的语句。
(2)完成类Rectangle的构造函数,请在注释//********2********后添加适当的语句。
(3)完成计算矩形对角线长度函数Diagonal0,请在注释//********3********后添加适当的语句。
(4)完成计算周长函数Girth(),请在注释//********4********后添加适当的语句。
程序输出:
50
140
注意:增加代码,或者修改代码的位置已经用符号表示出来。请不要修改其他的程序代码。
#include<iostream.h>
#include<cmath>
class Rectangle
{
public:
int left,right,top,bottom;
//********1********
{
left=1;
right=r;
top=t;
bottom=b;
}
//********2********
{
left=rc.left;
right=rc.right;
top=rc.top;
bottom=rc.bottom;
}
float Diagonal()
{
//********3********
return
}
int Girth()
{
//********4********
return
}
};
int main()
{
Rectangle rect(20,50,40,80);
Rectangle rect2(rect);
cout
rect2.Diagonal()
endl;
cout
rect2.Girth()
endl;
return 0;
}
问答题请使用VC6或使用[答题]菜单打开考生文件夹proj1下的工程projl,该工程含有一个源程序文件proj1.cpp。其中位于每个注释“//ERROR ****found****”之后的一行语句存在错误。请改正这些错误,使程序的输出结果为: The value is 10 注意:只修改注释“//ERROR ****found****”的下一行语句,不要改动程序中的其他内容。 //proj1.cpp #include <iostream> using namespace std; class MyClass int value; public: //ERROR********found******** void MyClass (int val):value(val) int GetValue()constreturn value; void SetValue(int val); ; //ERROR********found******** inline void SetValue(int val)value int main () MyClass obj(0); obj.SetValue(10); //ERROR********found********下列i语句功能是输出obj的成员 value的值 cout<<"The value is"<<obj.value<<endl; return 0;
问答题使用VC6打开
下的源程序文件modi2.cpp。阅读下列函数说明和代码,完成空出部分的程序。函数func(int A[NUM],int n)实现的功能是将数组的内容进行一次重新排序。排序的方法是:给定n,则下标为i的数字与下标为n-i的数字交换。从0开始,交换N/2次,则最后的内容为排序后的结果。
如果:A[8]={1,2,3,4,5,6,7,8}, n=6,则结果:A[8]={7,6,5,4,3,2,1,8}。
注意:不能修改其他代码。
#include <iostream.h>
#defime NUM 8
Void func(int A[NUM],int n)
{
}
int main()
{
int A[NUM]: (1,2,3,4,5,6,7,8);
func(A,6);
for(int i=0;i<sizeof(A)/sizeof(int); i++)
{
cout
A[i]
" ";
}
cout
endl;
return 0;
}
问答题使用VC6打开考生文件夹下的源程序文件modi2.cpp。请完成函数fun(int x),该函数功能是判定x的所有的约数,并且在函数中调用写函数WriteFile()将结果输出到modi2.txt文件中。
例如:x=10的约数为1,2,5,10。
注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构。
#include
#inClude
#include
using namespace std;
void WriteFile(int c)
{
ofstream out1;
out1.open("modi2.txt",ios
base::binary | ios_base::app);
out1<
问答题使用VC6打开考生文件夹下的源程序文件modi2.cpp。阅读下列函数说明和代码。函数MergeAndSort(int s[],int e[],int a[],int m,int n)实现将两个数组合并。这两个数组已经有序,按照由小到大的顺序排列。例如:e[]={1,3,5,6},m是数组e的长度,即为4。a[]={2,4,5,7,11,13},n是数组a的长度,即为6。则执行的结果为:s[]={1,2,3,4,5,6,7,11,13}补充函数fun(int s[],int e[],int a[],int m,int n),使之实现上述要求。注意:请勿改动主函数。#include<iostream.h>void MergeAndSort(int s[],int e[],int a[],int m,int n){}int main(){int data[20],i;int a[]=(1,3,5,6);int b[]={2,4,5,7,11,13};cout<<"a[]=";for(i=0;i<4;i++)cout<<a[i]<<',';cout<<endl;cout<<"b[]=";for(i=0;i<6;i++)cout<<b[i]<<',';cout<<endl;MergeAndSort(data,a,b,4,6);cout<<"s[]=";for(i=0;i<9;i++)cout<<data[i]<<',';cout<<endl;return0;}
问答题请编写类的成员函数char Buff=new char[Length]; ~CharArray () delete Buff; int GetLength () return Length; char private: int Length; char *Buff; ; char CharArray string1(6); char *string2="string"; for(cnt=0; cnt<8; cnt++) string1[cnt] = string2[cnt]; cout<<"/n"; for(cnt=0; cnt<8; cnt++) cout<<string1[cnt]; cout<<"/n"; cout<<string1.GetLength()<<endl;
问答题使用VC6打开考生文件夹下的源程序文件modil.cpp,但该程序运行时有错,请改正程序中的错误,使程序输出的结果为: i=5 i=10 i=15 i=20 注意:错误的语句在//*****error******的下面,修改该语句即可。#include<iostream.h>class CMyClass{public: template<class T> void func(T x,T y) { //*****error****** T i=0; if(x>=i) { i=i+x; } else f i=i+y; } cout<<"i="<<i<<end1; }};void main(){ CMyClass t; t.func(5,0); //*****error****** t.func(68,(char)1); float i=10.0; //*****error****** t.func(i,1); t.func(5,5);}
问答题请使用【答题】菜单命令或直接用VC6打开考生文件夹下的工程prog3,其中声明了ValArray类,该类在内部维护一个动态分配的整型数组。ValArray类的复制构造函数应实现对象的深层复制。请编写ValArray类的复制构造函数。在main函数中给出了一组测试数据,此种情况下程序的输出应该是:
ValArray vl={1,2,3,4,5} ValArray v2={1,2,3,4,5} 要求:
补充编制的内容写在“//*********333*********”与“//*********666*********”之间,不得修改程序的其他部分。
注意:程序最后将结果输出到文件out.dat中。输出函数write To File已经编译为boj文件,并且在本程序中调用。
//ValArray.h
#include using namespace std; class ValArray{
int *v: int size; public:
ValArray(const int * P,int n):size(n) {
v=new int[size];
for(int i=0;i
问答题请使用VC6或使用【答题】菜单打开
proj2下的工程proj2。其中有类Point(“点”)、Rectangle(“矩形”)和Circle(“圆”)的定义。在程序所使用的平面坐标系统中,x轴的正方向是水平向右的,y轴的正方向是竖直向下的。请在横线处填写适当的代码并删除横线,以实现上述类定义。此程序的正确输出结果应该是:
--圆形----------
圆心=(3,2)
半径=1
面积=3.14159
--外切矩形----------
左上角=(2,1)
右下角=(4,3)
面积=4
注意:只能在横线处填写适当的代码,不要改动程序中的其他内容,也不要删除或移动“// ****found****”。
#include <iostream>
#include <cmath>
using namespace std;
//平面坐标中的点
//本题坐标系统中,x轴的正方向水平向右,y轴的正方向竖直向下。
class Point {
public:
Point(double x=0.0, double y=0.0): x_(x), y_(y) {}
double getX() const {return x_;}
double getY() const {return y_;}
void setX(double x) {x_=x;}
void setY(double y) {y_=y;}
private:
double x_; //x坐标
double y_; //y坐标
};
//矩形
class Rectangle {
public:
Rectangle (Point p, int w, int h)
: point (p), width (w), height (h) {}
double area() const //矩形面积
{
return width * height;
}
Point topLeft() const //左上角顶点
{
return point;
}
Point bottomRight() const
//右下角顶点(注:y轴正方向竖直向下)
{
// **********found**********
return Point(______);
}
private:
Point point; //左上角顶点
double width; //水平边长度
double height; //垂直边长度
};
//圆形
class Circle {
public:
Circle (Point p, double r):center(p), radius(r) {}
Rectangle boundingBox() const; //外切矩形
double area() const //圆形面积
{
// **********found**********
return PI *______;}
public:
static const double PI; //圆周率
private:
Point center; //圆心
double radius; //半径
};
const double Circle::PI = 3.14159;
Rectangle Circle::boundingBox() const
{
// **********found**********
Point pt(______);
int w, h;
// **********found**********
w = h =______;
return Rectangle(pt, w, h);
}
int main ()
{
Point p(3, 2);
Circle c(p, 1);
cout << --圆形---------- /n";
cout << "圆心 = (" << p.getX() << "," << p.getY() << ")/n";
cout << "半径 =" << 1 << endl;
cout << "面积 =" << c.area() << endl << endl;
Rectangle bb = c.boundingBox();
Point t1 = bb.topLeft();
Point br = bb.bottomRight();
cout << "--外切矩形-----------/n";
cout << "左上角 = (" << t1.getX() << "," << t1.getY() << ")/n";
cout << "右下角 = (" << br.getX() << "," << br.getY() << ")/n";
cout << "面积 =" << bb.area() << endl;
return 0;
}
问答题使用VC6打开考生文件夹下的源程序文件modi3.cpp。通过继承完成输入到屏幕指定的信息:
TestClassA
TestClassB
TestClassC
其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。
(1)完成类B虚继承于A,请在注释∥********1********后添加适当的语句。
(2)完成类C虚继承于A,请在注释∥********2********后添加适当的语句。
(3)完成类D继承于B,C,请在注释∥********3********后添加适当的语句。
(4)函数Am通过调用基类的fun,完成所输出的内容,请在注释∥********4********后添加适当的语句。
注意:增加代码,或者修改代码的位置已经用符号表示出来。请不要修改其他的程序代码。
#include
clasS TestClassA
{
public:
void fun(){
cout<<"TestClassA”<
问答题使用VC6打开考生文件夹下的源程序文件modi2.cpp。阅读下列函数说明和代码,补充空出的代码。函数DecToBin(char*des,int n)的功能是将十进制数据n转换成二进制数据,并将转换结果存放在des中。
如:120的二进制数据为1111000
例:
DecToBin(char*des,1 20);
cout
#define MAXLEN 1024
void DecToBin(char*des,int n)
{
}
void main()
{
char des[MAXLEN];
int n=12 0;
DecToBin(des,n);
cout<
问答题请使用VC6或使用[答题]菜单打开考生目录proj3下的工程文件proj3,此工程包含一个源程序文件proj3.cpp,其中定义了用于表示二维向量的类MyVector;程序应当显示(6,8)。但程序中有缺失部分,请按照以下提示,把缺失部分补充完整:
(1)在“//**1** ****found****”的下方是构造函数的定义,它用参数提供的坐标对x和y进行初始化。
(2)在“//**2** ****found****”的下方是减法运算符函数定义中的一条语句。两个二维向量相减生成另一个二维向量:其X坐标等于两向量X坐标之差,其Y坐标等于两向量Y坐标之差。
(3)在“//**3** ****found****”的下方,语句的功能是使变量v3获得新值,它等于向量v1与向量v2之和。
注意:只在指定位置编写适当代码,不要改动程序中的其他内容,也不要删除或移动“****found****”。
//proj3.cpp
#include<iostream>
using std::ostream;
using std::cout;
using std::endl;
class MyVector{ //表示二维向量的类
double x; //X坐标值
double y; //Y坐标值
public:
MyVector (double i=0.0,double j=0.0); //构造函数
MyVector operator+(MyVector j);
//重载运算符+
friend MyVector operator-(MyVector i,MyVector j); //重载运算符-
friend ostream //重载运算符<<
};
//**1** **********found**********
______(double i,double j):x (i),y(j){}
MyVector MyVector::operator+(MyVector j) {
return MyVector(x+j.x,y+j y);
}
MyVector operator~(MyVector i,MyVector j)
{//**2** **********found**********
return MyVector (______);
}
ostream
}
int main ()
{
MyVector v1(2,3),v2(4,5),v3;
//**3** **********found**********
v3______;
cout<<v3<<endl;
return 0;
}
问答题请编写一个函数void bubble(double data[],int length),其中data是一维数组,存放比较的数据,length是数组中存放元素的个数,用冒泡法将数据(个数可变)捧序后由小到大输出。冒泡法是常用的排序算法,这种算法执行效率不高,但比较简单,就是将相邻的两个数据作比较,把较小的数据交换到前面。纵向看来,交换过程中较小的数据就好像水中的气泡不断浮起。要求使用for循环实现算法。 注意:部分源程序已存在文件test23_2.cpp中。 请勿修改主函数main和其他函数中的任何内容,仅在函数bubble的花括号中填写若干语句。 文件test23_.cpp的内容如下: #include<iostream.h> void bubble(double data[],int length) void main () int n; cout << "请输入数据的个数"; cin>>n; double* ddata = new double[n]; for(int i = 0; i < n; i++) cout<<"No."<<i+1<<": "; cin>>ddata[i]; bubble (ddata, n); cout<<"排序后输出数据:"<<endl; for(i = O; i<n; i++) cout<<"No."<<i+1<<":"; cout<<ddata[i]<<endl;
问答题请使用VC6或使用【答题】菜单打开考生文件夹proj2下的工程proj2,函数voidInsert(node*q)使程序能完成如下功能:从键盘输入一行字符,调用该函数建立反序单链表,再输出整个链表。注意:请勿修改主函数main和其他函数中的任何内容,只需在横线处编写适当代码,也不要删除或移动“//****found****”。//proj2.cpp#include<iostream>usingnamespacestd;Structnode{chardata;node*link;}*head;//链表首指针voidInsert(node*q)//将节点插入链表首部{//********found********________;head=q;}intmain(){charch;node*P;head=NULL;tout<<"Pleaseinputthestring"<<end1;while((ch=cin.get())!='n'){//********foHnd********________;//用new为节点p动态分配存储空间P->data=ch;//********found********________;//插入该节点}p=head;while(p!=NULL){tout<<p->data;p=p->iink;}tout<<end1;return0;}
问答题请使用VC6或使用【答题】菜单打开考生文件夹proj3下的工程proj3,其中使用友元函数访问类的私有数据成员,求出两个数据成员的大于1的最小公因子。请编写友员函数FriFun,使其输出结果为:Commnn denominator is 2 要求:补充编制的内容写在“//**********333**********”与“//**********666**********”之间,不得修改程序的其他部分。 注意:程序最后将结果输出到文件out.dat中。输出函数writeToFile已经编译为0bj文件,并且在本程序中调用。//proj3.h clasS FriFunClass{ int a,b;public: EriFunClass(int i,int j){a=i;b=j;) friend int FriFun(FriFunClass x); //友元函数 }; void writeToFile(const char*);//proj3.cpp#include<iostream>using namespace std;#include”prj3.h”int FriFun(FriFunClass X){//**********333********** //由于函数FriFun()是类FriFunclass的友元函数,所以它可以直接访问a和b//**********666**********}int main(){ FriFunClass n(10,20); if(FriFun(n)) tout;<<”Common denominat:or iS”<<FriFun(n) <<”\n”; else cout:<<”No commom denominator.\n”; writeToFile(””); return 0; }
问答题请使用菜单命令或直接用VC6打开
下的工程proj3,其中声明了Date类,它是一个用于表示日期的类。成员函数isLessThan用以比较两个日期的大小:当第一个日期早于第二个日期时,返回true,否则返回false。请补充完整函数isLessThan。在main函数中给出了一组测试数据,此情况下程序的输出应该是:
2007-06-21<2007-07-03
2007-06-21>=2007-06-19
2007-06-21<2010-01-01
注意:只需在函数isLessThan的//********333********和//********666********之间填入若干语句,不要改动程序中的其他内容。
#include"Date.h"
int main(){
Date date1(2007, 6, 21), date2(2007, 7, 3), date3(2007, 6, 19), date4(2010, 1, 1);
date1.show();
date1.isLessThan(date2)?cout<<" <":cout<<">=";
date2.show(); cout<<endl;
date1.show();
date1.isLessThan(date3)?cout<<"<":cout<<">=";
date3.show(); cout<<endl;
date1.show();
date1.isLessThan(date4)?cout<<" <":cout<<">=";
date4.show(); cout<<endl;
writeToFile("c:/test"); //不用考虑此语句的作用
return 0;
}
//proj3/Date.cpp
#include"Date.h"
void Date::show(ostream
}
bool Date::isLessThan(Date date)const{
//********333********
//********666********
}
//proj3/Date.h
#include<iostream>
#include<iomanip>
using namespace std;
class Date{
int year;
int month;
int day;
public:
Date(int y, int m, int d):year(y), month(m), day(d){}
int getYear()const{return year; }
int getMonth()const{return month; }
int getDay()eonst{return day; }
void show(ostream
bool operator==(Date date)const{
return year==date.year
}
bool isLessThan(Date date)const;
};
void writeToFile(const char*path);
问答题请使用VC6或使用[答题]菜单打开考生文件夹proj2下的工程proj2。此工程中包含一个源程序文件main.cpp,其中有类Point(“点”)、Circle(“圆”)和主函数main的定义。请在横线处填写适当的代码并删除横线,以实现上述定义,此程序的正确输出结果应为:
[30,50]
center=[120,89];radius=2.7
注意:只在横线处填写适当的代码,不要改动程序中的其他内容,也不要删除或移动“//********found********”。
#include <iostream>
#include <iomanip>
using namespace std;
class Point{ //点类
public:
//构造函数参数xValue为点的X坐标,yValue为点的Y坐标
//**********found**********
Point ( int xValue = 0, int yValue = 0)
{};
void setX ( int xValue ) { x = xValue; }
int getX() { return x; }
void setY( int yValue ) { y = yValue; }
int getY () { return y; } //声明虚函数Disp()
//********** found**********
{cout << '[' << getX() << ", " <<getY() <<']'; };
private:
int x; // x 坐标
int y; // y 坐标
};
class Circle : public Point{ //圆类
public: //构造函数参数xValue为圆心的X坐标,yValue为圆心的Y坐标
Circle( int xValue=0, int yValue=0, double radiusValue=0.0)
//********** found**********
______{}
void setRadius (double radiusValue)
{radius = ( radiusValue < 0.0 ? 0.0 : radiusValue); }
double getRadius () { return radius; }
double getDiameter () { return 2 * getRadius (); }
double getCircumference() { return 3.14159 * getDiameter() ;} //计算周长
double getArea () { return 3.14159 * getRadius () * getRadius (); } //计算面积
void Disp() //输出圆对象
{ cout << "center = "; Point::Disp();
cout << "; radius = " << getRadius();
}
private:
double radius; //圆半径
};
int main ()
{
Point point ( 30, 50 );
Circle circle( 120, 89, 2.7 );
Point * pointPtr;
pointPtr =
pointPtr -> Disp ();
cout << endl;
pointPtr = //将派生类对象
pointPtr -> Disp ();
return 0;
}
问答题请使用VC6或使用【答题】菜单打开考生文件夹proj3下的工程proj3,其中声明的IntSet是一个用于表示正整数集合的类。IntSet的成员函数Merge的功能是求当前集合与另一个集合的并集,在Merge中可以使用成员函数IsMemberOf判断_个正整数是否在集合中。请完成成员函数Mellge。在main函数中给出了一组测试数据,此时程序的输出应该是:求并集前:123581028911305667求并集后:1235810289113056671235810911305667要求:补充编制的内容写在“//**********333**********”与“//**********666**********”之间,不得修改程序的其他部分。注意:程序最后将结果输出到文件out.dat中。输出函数writeToFile已经编译为obj文件,并且在本程序中调用。//Intset.h#include<iostream>usingnamespacestd;constintMax=100;classIntSet{public:IntSet()//构造一个空集合{end=-1;}IntSet(inta[],intsize)//构造一个包含数组a中size个元素的集合{if(Size>=Max)end=Max-;elseend=size-1;for(inti=0;i<=end;i++)element[i]=a[i];}boolIsMemberOf(inta)//判断a是否为集合中的元素{for(inti=0;i<=end;i++)if(element[i]:=a)returntrue;returnfalse;}intGetEnd(){returnend;)//返回最后一个元素的下标intGetElement(inti){returnelement[i];}//返回下标i处的元素IntSetMerge(IntSet&set);//求当前集合与集合set的并集voidPrint()//输出集合中的所有元素{for(inti=0;i<=end;i++)if((i+1)%20=0)cout<<element[i]<<end1;elsecout<<element[i]<<',';cout<<end1;}private:intelement[Max];intend;};voidwriteToFile(constchar*);//main.cpp#include"IntSet.h"IntSetIntSet::Merge(IntSet&set){inta[Max],size=0;//********333********//********666********returnIntSet(a,size);}intmain(){inta[]={1,2,3,5,8,i0};intb[]={2,8,9,ii,30,56,67};IntSetsetl(a,6),set2(b,7),set3;cout<<"求并集前:"<<end1;set1.Print();set2.Print();set3.Print();set3=set1.Merge(set2);cout<<end1<<"求并集后:"<<end1;set1.Print();set2.Print();set3.Print();writeToFile("");return0;}
问答题请使用VC6或使用【答题】菜单打开
proj2下的工程proj2,此工程中包含一个头文件shape.h,其中包含了类Shape、Point和Triangle的声明;包含程序文件shape.cpp,其中包含了类Triangle的成员函数和其他函数的定义;还包含程序文件proj2.cpp,其中包含测试类Shape、Point和Triangle的程序语句。请在程序中的横线处填写适当的代码并删除横线,以实现上述功能。此程序的正确输出结果应为:
此图形是一个抽象图形,周长=0,面积=0
此图形是一个三角形,周长=6.82843,面积=2
注意:只能在横线处填写适当的代码,不要改动程序中的其他内容,也不要删除或移动“// ****found****”。
//shape.h
class Shape {
public:
virtual double perimeter() const {return 0;} //返回形状的周长
virtual double area() const {return 0;} //返回形状的面积
virtual const char * name() const {return "抽象图形";} //返回形状的名称
};
class Point{ //表示平面坐标系中点的类
double x;
double y;
public:
// **********found**********
Point (double x0, double y0):
______{} //用x0、y0初始化数据成员x、y
double getX() const {return x;}
double getY() const {return y;}
};
class Triangle: public Shape{
// **********found**********
______;
//定义3个私有数据成员
public:
Triangle (Point p1, Point p2, Point p3): point1 (p1), point2 (p2), point3 (p3) {}
double perimeter () const;
double area() const;
const char * name() const {return "三角形";}
};
//shape.cpp
#include "shape.h"
#include <cmath>
double length (Point p1, Point p2)
{
return sqrt ((p1.getX() -p2.getX()) * (p1.getX() -p2.getX()) + (p1.getY() -p2.getY()) * (p1.getY() -p2.getY()));
}
double Triangle:: perimeter () const
{//一个return语句,它利用length函数计算并返回三角形的周长
// **********found**********
______;
}
double Triangle::area() const
{
double s = perimeter()/2.0;
return sqrt (s * (s - length (point1, point2)) * (s - length (point2, point3)) * (s - length (point3, point1)));
}
//proj2.cpp
#include "shape.h"
#include <iostream>
using namespace std;
// **********found**********
______ //show函数的函数头(函数体以前的部分)
{
cout << "此图形是一个" << shape.name() << ",周长=" << shape.perimeter() << ",面积=" << shape.area() << endl;
}
int main()
{
Shape s;
Triangle tri(Point(0,2), Point(2,0), Point(0,0));
show(s);
show(tri);
return 0;
}
问答题请使用VC6或使用【答题】菜单打开proj2下的工程proj2,该工程中包含一个程序文件main.cpp,其中有坐标点类point、线段类Line和三角形类Triangle的定义,还有main函数的定义。程序中两点间距离的计算是按公式实现的,三角形面积的计算是按公式实现的,其中请在程序中的横线处填写适当的代码,然后删除横线,以实现上述类定义。此程序的正确输出结果应为:Side1:9.43398Side2:5Side3:8area:20注意:只在横线处填写适当的代码,不要改动程序中的其他内容,也不要删除或移动“//****found****”。#include<iostream>#include<cmath>usingnamespacestd;classPoint{//坐标点类public:constdoublex,y;Point(doublex=0.0,doubley:0.0):x(x),y(y){}//**********found********doubledistanceTo(______)const{//到指定点的距离returnsqrt((x-p.x)*(x-p.x)+(y-p.y)*(y-p.y));}};classLine{//线段类public:constPointp1,p2;//线段的两个端点//**********found**********Line(Pointp1,Pointp2):______{}doublelength()const{returnp1.distanceTo(p2);}//线段的长度};classTriangle{//三角形类public:constPointp1,p2,p3;//三角形的三个顶点//**********found**********Triangle(______):p1(p1),p2(p2),p3(p3){}doublelength1()const{//边p1,p2的长度returnLine(p1,p2).length();}doublelength2()const{//边p2,p3的长度returnLine(p2,p3).length();}doublelength3()const{//边p3,p1的长度returnLine(p3,p1).length();}doublearea()const{//三角形面积//********found*********doubles=______;returnsqrt(s*(s-length1())*(s-length2())*(s-length3()));}};intmain(){Triangler(Point(0.0,8.0),Point(5.0,0.0),Point(0.0,0.0));cout<<"Side1:"<<r.length1()<<endl;cout<<"Side2:"<<r.length2()<<endl;cout<<"Side3:"<<r.length3()<<endl;cout<<"area:"<<r.area()<<endl;return0;}
