![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 |
|
Programming Guru
![]() ![]() ![]() |
yeah..
while ( ; ; ) and for (EVER) are infinite loops... they have to have an exit condition. I defined EVER as ; ; because I thought it was cooler saying forever as opposed to the other stuff. This way or the way you are mentioning in your post above would work... all that really matters is that you have the while loop playing a part somewhere... lol good luck dude
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." |
|
|
|
|
|
#12 |
|
Programming Guru
![]() ![]() ![]() |
oops... i don't think the ;; works with a while loop...
you can do this and still maintain the forever stuff... #define FOREVER true while (FOREVER) { GetNums(); }
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." |
|
|
|
|
|
#13 |
|
Programming Guru
![]() ![]() ![]() |
(thats odd, thought you replied with the WHILE (;
stuff not working... your reply seems to have disappeared... at any rate, you can do the FOREVER as a boolean as I have it above to take care of that problem)
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." |
|
|
|
|
|
#14 |
|
Programming Guru
![]() Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 5
![]() |
define EVER ;; for (EVER) lol...
__________________
i put on my robe and wizard hat... Have you ever heard of Plato, Aristotle, Socrates?...Morons. |
|
|
|
|
|
#15 |
|
Hobbyist Programmer
Join Date: Mar 2005
Location: Illinois--> My room
Posts: 117
Rep Power: 0
![]() |
u ruined it...
__________________
Support Our Troops |
|
|
|
|
|
#16 |
|
Troll
Join Date: Apr 2005
Location: Texas
Posts: 732
Rep Power: 4
![]() |
Why the complexity? Instead of an array, have a single int variable (Like IR, but no function calls. No need for the pushes and calls). Every time you get input, if it the input is larger than the current variable, set the variable to the input. When you exit the loop, the variable will already be set to the max. It is both efficient in memory and speed. Excuse my syntax, and crappy exit condition (Is there a command to exit a loop?):
bool exiting = false;
int max = 0;
int input = 0;
while (!exiting) {
cout << "Number, or -1 to exit: " << endl;
cin >> input;
if (input > max) { max = input; (need a semicolon?) }
if (input == -1) {
cout << "Max: " << max;
exiting = true;
}
}
return 0; |
|
|
|
|
|
#17 |
|
Hobbyist Programmer
Join Date: Mar 2005
Location: Illinois--> My room
Posts: 117
Rep Power: 0
![]() |
because someone like me looks at things too hard, and I try to analyze everything to the finest detail. You should watch me solve my brothers 3rd grade math problems....
ok that was a joke, but I seriously do analyze things very hard. I guess I just overestimate everything Thanks Dameon for your advice
__________________
Support Our Troops |
|
|
|
|
|
#18 |
|
Programming Guru
![]() ![]() ![]() |
i was under the impression that it had to be relatively complex.... being a school assignment. but yes, admittingly so, I over-analyze everything as well. I'll spend days on a trivial problem sometimes. Anyhow, to exit the loop you could use break() or exit(0);
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|