I had many excellent, engaging, exciting history teachers. My Latin teacher was quirky and annoying, but loved the subject and it rubbed off on us. My biology teacher made me think I wanted to go into hard sciences.
I barely remember my math teachers. And I was good at math.
I don't believe my experience is unique.
A dedicated and charismatic professor might be instrumental in turning an interested computer science student into a raging algorithmist (indeed, I actually think a lot of computer science grad students study what they study because somebody appropriately passionate introduced it to them), but converting a just-here-for-the-requirement high schooler is a different story.
Personally, I got into CS because there was a required intro class at my undergrad. A dedicated and charismatic professor noticed my aptitude and encouraged me to take the next course and consider a CS major. This could easily have happened in high school if my high school had a required CS course.