The correct answer is "The chimpanzees entertained the children who visited the zoo." This is because the sentence implies that the children were the ones who visited the zoo, and the chimpanzees entertained them. The first sentence, "While visiting the zoo, the chimpanzees entertained the children," suggests that the chimpanzees themselves were visiting the zoo, which does not make logical sense. Therefore, the second sentence is the correct interpretation.