struct item { double w, v; const char *name; } items[] = {
	{ 3.8, 36,  },
	{ 5.4, 43,  },
	{ 3.6, 90,  },
	{ 2.4, 45,  },
	{ 4.0, 30,  },
	{ 2.5, 56,  },
	{ 3.7, 67,  },
	{ 3.0, 95,  },
	{ 5.9, 98,  },
};

int item_cmp(const void *aa, const void *bb)
{
	const struct item *a = aa, *b = bb;
	double ua = a->v / a->w, ub = b->v / b->w;
	return ua < ub ? -1 : ua > ub;
}

int main()
{
	struct item *it;
	double space = 15;

	qsort(items, 9, sizeof(struct item), item_cmp);
	for (it = items + 9; it---items && space > 0; space -= it->w)
		if (space >= it->w)
			printf(, it->name);
		else
			printf(,
				space, it->w, it->name);

	return 0;
}