Computer Science Canada How to Loop? |
Author: | jamonathin [ Thu May 05, 2005 8:59 am ] |
Post subject: | How to Loop? |
How can you run just a basic loop? What I'm trying to do is make this program (http://www.compsci.ca/v2/viewtopic.php?t=8675) and I can do everything, but loop. Any suggestions? |
Author: | rdrake [ Thu May 05, 2005 11:10 am ] | ||||
Post subject: | |||||
If you're using C, something like
If you're trying to make a for loop, then
|
Author: | jamonathin [ Thu May 05, 2005 1:19 pm ] | ||
Post subject: | |||
Im using C++, and so how would I go about exiting the loop though. The type of loop Im looking for is just like the one in turing
|
Author: | wtd [ Thu May 05, 2005 1:40 pm ] | ||
Post subject: | |||
Well, something like:
|
Author: | jamonathin [ Fri May 06, 2005 1:20 pm ] |
Post subject: | |
sweet, thanks man. |
Author: | MysticVegeta [ Mon Jun 20, 2005 8:04 am ] | ||
Post subject: | |||
I came across a C++ book and another way to infinite loop is ->
I think it works |
Author: | 1of42 [ Mon Jun 20, 2005 7:22 pm ] | ||
Post subject: | |||
Or, to be cute...
|
Author: | wtd [ Tue Jun 21, 2005 2:19 am ] |
Post subject: | |
Being cute in such languages isn't cute. |
Author: | 1of42 [ Tue Jun 21, 2005 11:34 am ] |
Post subject: | |
Well, you could just go spoil ALL my fun... *pouts* |
Author: | wtd [ Tue Jun 21, 2005 12:09 pm ] |
Post subject: | |
1of42 wrote: Well, you could just go spoil ALL my fun... *pouts*
The problem is that some student will come in here, see that, and consider it the best way to loop. |
Author: | MysticVegeta [ Tue Jun 21, 2005 4:05 pm ] |
Post subject: | |
wtd wrote: The problem is that some student will come in here, see that, and consider it the best way to loop. |
Author: | 1of42 [ Tue Jun 21, 2005 5:58 pm ] |
Post subject: | |
MysticVegeta wrote: illegal use of vars
s'not a var, just a text substitution |
Author: | Cinjection [ Wed Jun 22, 2005 5:51 pm ] | ||
Post subject: | |||
Programming's an art, NOT a science. This is very debatable, but that's my opinion. If you find a creative or fun way of doing something, you shouldn't be penalised for it. As long as it's not really bad coding style....like goto or something. I ALWAYS make my first for loop var 'c' so i can go:
|
Author: | wtd [ Wed Jun 22, 2005 5:54 pm ] |
Post subject: | |
1of42 wrote: MysticVegeta wrote: illegal use of vars
s'not a var, just a text substitution Which is bad, because it means that the code you're seeing, and the code the compiler is seeing are different. |
Author: | 1of42 [ Wed Jun 22, 2005 9:51 pm ] |
Post subject: | |
wtd wrote: Which is bad, because it means that the code you're seeing, and the code the compiler is seeing are different.
Never said it wasn't bad, it's just not an illegal use of variables. It's a bad practice, that's all. And Cinjection - I do that too |
Author: | wtd [ Wed Jun 22, 2005 10:59 pm ] | ||
Post subject: | |||
Cinjection:
Aside from the added spacing, I use initilization, rather than assignment, and the prefix form of incrementing. Good habits to get into. |
Author: | 1of42 [ Thu Jun 23, 2005 2:07 am ] |
Post subject: | |
see, i was gonna point all that out, but it just ruins all the fun of c++ (pun intended). |
Author: | Cinjection [ Thu Jun 23, 2005 9:04 am ] |
Post subject: | |
I know that code is bad. I never pull those single-liners, but you really got to stop correcting mock code! |