Small Triangles, Large Triangles

Sort by

recency

|

441 Discussions

|

  • + 0 comments

    include

    include

    include

    struct triangle { int a; int b; int c; };

    typedef struct triangle triangle; triangle* sort_by_area(triangle* tr, int n) { /** * Sort an array a of the length n / double p ; double k = malloc(n * sizeof(double)); ; triangle temp; for(int i =0; i(p-tr[i].b)(p-tr[i].c));

    }
    for (int i =0;i<n;i++){
        for(int j = 0;j<n-i-1;j++){
            if(k[j]>k[j+1]){
                temp = tr[j];
                tr[j] = tr[j+1];
                tr[j+1] = temp;
                double tempk = k[j];
                k[j] = k[j + 1];
                k[j + 1] = tempk;
            }
            else{
                continue;
            }   
        }
    }
    free(k);
    return tr;
    

    }

    int main() { int n; scanf("%d", &n); triangle *tr = malloc(n * sizeof(triangle)); for (int i = 0; i < n; i++) { scanf("%d%d%d", &tr[i].a, &tr[i].b, &tr[i].c); } sort_by_area(tr, n); for (int i = 0; i < n; i++) { printf("%d %d %d\n", tr[i].a, tr[i].b, tr[i].c); } return 0; }

  • + 0 comments

    Whether you're thinking of geometry, design, art, or even metaphorical contexts, the idea of "Small Triangles, Large Triangle" seems to highlight the relationship between parts and the whole. It could suggest the way small elements contribute to a larger, unified structure or idea. Cricket Adda

  • + 0 comments
    hlo can any one tell me that how to solve this problem without using the nested for loop.
    
    void sort_by_area(triangle* tr, int n) {
        double* area = (double*)malloc(n*sizeof(triangle));
    	for(int i = 0; i<n;i++){
            double p = (tr[i].a+tr[i].b+tr[i].c)/2.0;
            area[i] = sqrt(p*(p-tr[i].a)*(p-tr[i].b)*(p-tr[i].c));
        }
    
        for(int i =0;i<n-1;i++){
            for(int j = 0;j<n-1;j++){
                if(area[j] > area[j+1]){
                    double tempo = area[j];
                    area[j] = area[j+1];
                    area[j+1] = tempo;
                    triangle temp = tr[j];
                    tr[j] = tr[j+1];
                    tr[j+1] = temp;
                }
            }
        }
        free(area);
        area = NULL;
    }
    
  • + 0 comments

    In geometry, comparing small triangles and large triangles often relates to similarity and scaling. Two triangles of different sizes may still be similar if their corresponding angles are equal and their sides are in proportion. Winbuzz Bet

  • + 0 comments

    include

    include

    include

    struct triangle { int a; int b; int c; };

    typedef struct triangle triangle; void sort_by_area(triangle* tr, int n) { double t,area[n]; for(int i=0; iarea[j+1]){ triangle temp=tr[j]; tr[j]=tr[j+1]; tr[j+1]=temp; } } } }

    int main() { int n; scanf("%d", &n); triangle *tr = malloc(n * sizeof(triangle)); for (int i = 0; i < n; i++) { scanf("%d%d%d", &tr[i].a, &tr[i].b, &tr[i].c); } sort_by_area(tr, n); for (int i = 0; i < n; i++) { printf("%d %d %d\n", tr[i].a, tr[i].b, tr[i].c); } return 0; }