lab1.cpp

来自「自动生成矩阵 输入数字 两个数字 饥渴」· C++ 代码 · 共 40 行

CPP
40
字号
#include <cmath>
#include <iostream>

using namespace std;

#include "Point.h"

double computeArea(Point &a, Point &b, Point &c);

int main()
{
	double x, y, z;

	cout<< "insert the a: ";
	cin >>x>>y>>z;
	Point a( x, y , z );

	cout<< "insert the b: ";
	cin >>x>>y>>z;
	Point b( x, y , z );

	cout<<"insert the c: ";
	cin >>x>>y>>z;
	Point c( x, y , z );

	cout<<"The area of triangle is: "
		 <<computeArea( a, b, c );
	return 0;
}

double computeArea(Point &a, Point &b, Point &c)
{
	double d1=a.distanceTo ( b );
	double d2=b.distanceTo ( c );
	double d3=c.distanceTo ( a );
	double p=( d1 + d2 + d2 ) / 2;
	return sqrt(p * ( p - d1 ) * ( p - d2 ) * ( p - d3 ) );
	
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?