Mr. Head, I'd like you to meet Mr. Wall
Feb. 4th, 2004 07:44 pmSo, I finally started USACO training, and one of the first things I've realized is, I need to relearn C++. I have no problem with C, but I really don't remember many of the basic mechanisms of C++.
I also apparently need a good smack on the head.
See, on the second problem, gift1, I run into a problem - absolutely nothing is getting output. Running it through the debugger, I find that, for whatever reason, all the for loops - pretty much the whole program - is getting skipped over. I spend who knows how long reconfirming that yes, i==0, and yes, num==5, and yes, therefore i<num, so why won't it enter the for loop?!
The solution arose on the bus to school today. I asked Tom about it. I say to him, "It's just for(int i=0;i++;i<num)", and he just starts laughing and points out that I have apparently forgotten how to do for loops, as it goes initial, condition, increment, not initial, increment, condition. "Even in BASIC it goes initial, condition, increment, in a sense!" So the loops never entered because obviously i++ would evaluate to 0. Idiot me.
-Sniffnoy
--
Guybrush: You're about as fearsome as a doorstop.
Murray: Is it a really EVIL looking doorstop?
-The Curse of Monkey Island
I also apparently need a good smack on the head.
See, on the second problem, gift1, I run into a problem - absolutely nothing is getting output. Running it through the debugger, I find that, for whatever reason, all the for loops - pretty much the whole program - is getting skipped over. I spend who knows how long reconfirming that yes, i==0, and yes, num==5, and yes, therefore i<num, so why won't it enter the for loop?!
The solution arose on the bus to school today. I asked Tom about it. I say to him, "It's just for(int i=0;i++;i<num)", and he just starts laughing and points out that I have apparently forgotten how to do for loops, as it goes initial, condition, increment, not initial, increment, condition. "Even in BASIC it goes initial, condition, increment, in a sense!" So the loops never entered because obviously i++ would evaluate to 0. Idiot me.
-Sniffnoy
--
Guybrush: You're about as fearsome as a doorstop.
Murray: Is it a really EVIL looking doorstop?
-The Curse of Monkey Island