You've got a few problems:
- You need to change
s
andp
fromint
s todouble
s (otherwise you'll get unwanted truncation of your results). - You need to change
double y[2];
todouble y[3];
(since you need three side lengths, not two). - Change
s = sqrt(p * (p - y[0]) * (p - y[1]) * (p - y[3]));
tos = sqrt(p * (p - y[0]) * (p - y[1]) * (p - y[2]));
(sincey[3]
is out of bounds of your array).
Note also that you can get rid of your array x
, since you don't seem to actually use it anywhere.