Ironically, I actually considered going into the military, was forbidden by my mother due to said harassment, and ended up at an engineering school, studying computer science. I ended up getting my cs degree but also a literature degree at the same time to keep me sane.
There were only 5 other females in my 300+ graduating class and maybe 2-3 in my actual classrooms at any given time. As freshmen, most of my female friends dropped out of the major and in some cases, the school at large, to go to a liberal arts college instead. My friend doing comp sci at a state school also dropped out of that major, too, and chose history. This was all several years ago.
I wouldn't say I was stalked or harassed. I actually would say there seemed to be communication issues, with other students, TAs, and professors. Profs and TAs told me and another female friend we just needed to program more. They couldn't explain things. This was true in some ways -- when I finally found a language that suited me, and I just started programming random stuff, things started to make a lot more sense. I was also really helped by my future life-partner who had the patience and know-how to answer my vital questions. When I sat in algorithms class, and the prof told us "Just make a class, with whatever member variables you want.", I'd wonder, "How? I can't just... make stuff up. How will the compiler know to do that? Why would it listen to me? It can't be as easy as just typing out a definition. That doesn't *do* anything." I was not willing to just accept the 'magic' there. There were many sticking points like that. Luckily, my SO was a C++ god, and once I understood the foundation or resolved any mental conflicts, everything fell into place.
You can make a strong case that the above is an overall teaching issue. (For instance, the situation was actually worse when the professor was female.) I do think that it is fair to at least wonder if male and female brains process info differently, due either to genetics or cultural emphasis on certain tasks. If so, maybe those brains need to approach certain subjects in different ways, too. Someone more verbally-oriented might need more 'why' instead of just 'how'.