Small Triangles, Large Triangles

  • + 0 comments

    This is also one of the same way double area(triangle tr) { double s=(tr->a+tr->b+tr->c)/2.0; if((tr->a+tr->b)>tr->c&&(tr->b+tr->c)>tr->a&&(tr->a+tr->c)>tr->b) { double area=sqrt(s(s-tr->a)(s-tr->b)(s-tr->c)); return area;

    }
    return 0;
    

    }

    void sort_by_area(triangle* tr, int n) {

    double arr[n];
    for(int i=0;i<n;i++)
    {
         arr[i]=area(&tr[i]);
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<i;j++)
        {
            if (j == i)
            {
              arr[j] = arr[i]; 
            }
            if(arr[j]>arr[i])
            {
                double temp_1=arr[j];
                arr[j]=arr[i];
                arr[i]=temp_1;
                triangle temp=tr[j];
                tr[j]=tr[i];
                tr[i]=temp;
            }
        }
    
    }
    

    }