#include #include typedef struct { int id; double greutate, castig; }Obiect; int cmpObiecte(const void *a, const void *b) // ord descr { Obiect va = *(Obiect *)a; Obiect vb = *(Obiect *)b; if (va.castig /va.greutate < vb.castig / vb.greutate) return 1; if (va.castig /va.greutate > vb.castig / vb.greutate) return 0; } int main() { int n,i; double G, ct, auxG, p; Obiect *ob; FILE *fin, *fout; fin = fopen("rucsac.in","r"); fscanf(fin,"%d",&G); fscanf(fin,"%d",&n); ob = (Obiect*) malloc(n*sizeof(Obiect)); for (i=0; i