This question already has an answer here:
I read this story 30+ years ago in grade school. A man crashes on an alien planet. He has a small amount of water and accidentally spills some, and the planet replicates it but it must destroy part of itself to do so. The man then finds some stale crumbs in his pocket, puts them in a trough, and the planet replicates them as well, but it's disgusting to eat. The man eventually decides that his situation is hopeless, so he lays down to die on a table in a hot room and thinks he can at least give back to the planet some of the nutrients it sacrificed for him. He falls asleep, and when he awakens, he has been transformed into an alien creature that is perfectly suited and adapted to live on the planet without discomfort to himself or damage the planet.