We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Why does my code compile differently in vscode than in the test case here?
#include<stdio.h>#include<stdlib.h>#include<math.h>structtriangle{inta;intb;intc;};typedefstructtriangletriangle;doublesquart(triangletriangle){doublep=(triangle.a+triangle.b+triangle.c)/2.0;doubles=sqrt((double)(p*(p-triangle.a)*(p-triangle.b)*(p-triangle.c)));returns;}voidsort_by_area(triangle*tr,intn){/** * Sort an array a of the length n */inttap=n/2;for(tap;tap>0;tap/=2){for(inti=tap;i<n;i++){for(intj=i-tap;j>=0&&squart(tr[j])>squart(tr[j+tap]);j-=tap){triangletemp=tr[j];tr[j]=tr[j+tap];tr[j+tap]=temp;}}}}intmain(){intn;scanf("%d",&n);triangle*tr=malloc(n*sizeof(triangle));for(inti=0;i<n;i++){scanf("%d%d%d",&tr[i].a,&tr[i].b,&tr[i].c);}sort_by_area(tr,n);for(inti=0;i<n;i++){printf("%d %d %d\n",tr[i].a,tr[i].b,tr[i].c);// printf(" s = %.2lf", squart(tr[i]));}return0;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Small Triangles, Large Triangles
You are viewing a single comment's thread. Return to all comments →
Why does my code compile differently in vscode than in the test case here?