Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- struct Point {
- int x, y ;
- Point (){
- x=0;
- y=0;
- }
- Point (int _x , int _y){
- x=_x;
- y=_y;
- }
- double dis (Point another ){
- double res= sqrt( (x-another.x)* (x-another.x) + (y-another.y)*(y-another.y) );
- return res;
- }
- };
- struct Triangle{
- Point p1;
- Point p2;
- Point p3 ;
- Triangle (Point _p1, Point _p2, Point _p3 ){
- p1=_p1;
- p2=_p2;
- p3=_p3;
- }
- double sumDistance ( Point another ){
- double total = p1.dis(another) + p2.dis ( another ) + p3.dis(another);
- return total;
- }
- };
- //Sinh viên viết code vào đây
- int main(){
- // CHÚ Ý: Sinh viên không được thay đổi nội dung hàm main
- // Chương trình thay đổi hàm main sẽ không được tính điểm dù đúng tất cả các test
- int x1, y1, x2, y2, x3, y3, x, y;
- cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x >> y;
- Point p1(x1, y1);
- Point p2(x2, y2);
- Point p3(x3, y3);
- Triangle t(p1, p2, p3);
- Point p(x,y);
- cout << t.sumDistance(p) << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment