Cedric didn't give Harry a direct clue. After the First Task, he simply told Harry:
"Listen to the egg. It'll tell you what the next task is."
What Cedric figured out: Submerging the egg in water (the Prefects' bathroom) revealed a mermaid song describing the Second Task: retrieving something stolen from the merpeople in the Black Lake.
What Harry did: He ignored the egg for weeks. Only after Dobby (in the book) or Moody/Crouch Jr. (in the film) prompted him to open it underwater did he hear the clue—after Cedric had already solved it.
Cedric's sportsmanship in sharing even that vague hint contrasts with the Tournament's cutthroat nature.