Small Triangles, Large Triangles

  • + 0 comments

    9/11 test cases failed, 2 test case pass:

    where i'm wrong

    double area(triangle tr){ double s = (double)(tr.a + tr.b + tr.c)/2; return sqrt(s * (s - tr.a) * (s - tr.b) * (s - tr.c)); }

    // using bubble sort algo.... void sort_by_area(triangle* tr, int n) { /** * Sort an array a of the length n */

    for (int j=0; j<n-1; j++) {
        for(int i = 0; i< n-j-1; i++){
           double area1, area2;
           triangle temp;
           area1 = area(tr[i]);
           area2 = area(tr[i+1]);
    
            if(area1 > area2){
            temp = tr[i];
            tr[i] = tr[i+1];
            tr[i+1] = temp;
        }
    
        }
    }
    

    }~