Advertisement
anhkiet2507

Untitled

Sep 6th, 2021
2,314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.15 KB | None | 0 0
  1. #include<iostream>
  2. #include<cmath>
  3. #include<iomanip>
  4. #include<string>
  5. #include<stdio.h>
  6. #define PI 3.141592653589793238
  7. struct TamGiac{
  8.     double AB;
  9.     double BC;
  10.     double AC;
  11. };
  12. double DoDaiCanh(double a, double b, double c, double d){
  13.     double x = sqrt(pow(c-a,2)+pow(d-b,2));
  14.     return x;
  15. }
  16. int TamGiac(double a, double b, double c){
  17.     if((a+b)<c||(b+c)<a||(a+c)<b){
  18.         return 0;
  19.     }
  20.     return 1;
  21. }
  22. using namespace std;
  23.  
  24. int main() {
  25.     int t;
  26.     cin >> t;
  27.     while(t--){
  28.         struct TamGiac tg;
  29.         double xa, ya, xb, yb, xc, yc;
  30.         cin >> xa >> ya >> xb >> yb >> xc >> yc;
  31.         tg.AB = DoDaiCanh(xa, ya, xb, yc);
  32.         tg.AC = DoDaiCanh(xa, ya, xc, yc);
  33.         tg.BC = DoDaiCanh(xb, yb, xc, yc);
  34.         if(TamGiac(tg.AB, tg.AC, tg.BC)==1){
  35.             double DienTich = (1/4)*sqrt((tg.BC+tg.AC+tg.AB)*(tg.BC+tg.AC-tg.AB)*(tg.AC+tg.AB-tg.BC)*(tg.AB+tg.BC-tg.AC));
  36.             double Ketqua = (tg.BC*tg.AC*tg.AB)/(4*DienTich);
  37.             cout << fixed << setprecision(3) << tg.AB << " " << tg.AC << " " << tg.BC << endl;
  38.         }else{
  39.             cout << "INVALID" << endl;
  40.     }
  41.     }
  42. }
  43.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement