Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Apr 10th, 2005, 10:59 PM   #11
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,467
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
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."
Infinite Recursion is offline   Reply With Quote
Old Apr 10th, 2005, 11:13 PM   #12
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,467
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
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."
Infinite Recursion is offline   Reply With Quote
Old Apr 10th, 2005, 11:15 PM   #13
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,467
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
(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."
Infinite Recursion is offline   Reply With Quote
Old Apr 11th, 2005, 8:12 PM   #14
bl00dninja
Programming Guru
 
bl00dninja's Avatar
 
Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 5 bl00dninja is on a distinguished road
define EVER ;;

for (EVER)

lol...
__________________
i put on my robe and wizard hat...

Have you ever heard of Plato, Aristotle, Socrates?...Morons.
bl00dninja is offline   Reply With Quote
Old Apr 11th, 2005, 8:19 PM   #15
massive-war
Hobbyist Programmer
 
massive-war's Avatar
 
Join Date: Mar 2005
Location: Illinois--> My room
Posts: 117
Rep Power: 0 massive-war is an unknown quantity at this point
u ruined it...
__________________
Support Our Troops
massive-war is offline   Reply With Quote
Old Apr 11th, 2005, 8:30 PM   #16
Dameon
Troll
 
Dameon's Avatar
 
Join Date: Apr 2005
Location: Texas
Posts: 732
Rep Power: 4 Dameon is on a distinguished road
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;
Dameon is offline   Reply With Quote
Old Apr 11th, 2005, 9:06 PM   #17
massive-war
Hobbyist Programmer
 
massive-war's Avatar
 
Join Date: Mar 2005
Location: Illinois--> My room
Posts: 117
Rep Power: 0 massive-war is an unknown quantity at this point
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
massive-war is offline   Reply With Quote
Old Apr 11th, 2005, 11:03 PM   #18
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,467
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
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."
Infinite Recursion is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:53 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC