The program should display at least 50 numbers and sort it from lowest to highest.
How can you write a random generated C++ program?
do your homework, it is good for you.
Reply:well
u have to use a seed that gives time(0) for intializing
then use rand() function , (if it's not important for u that what kind of numbers will generate)
then use a loop (a for or while and even if loop might help), u know how.
store these nums into an array ( do this in the loop u've defined) i mean each time that rand generates a number u have to store it in one of the array places! :D
then use bubble sort to sort it (look at arrays chapter in deitel's c++ boook ;)
ok i think it might help
;)
Reply:int hw_sucks[50];
for(lcv = 0; lcv %26lt; 50; lcv++)
hw_sucks[lcv] = get_random_number(low, high); //Write this on your own, or use the random function provided by C.
Man qsort(), it will sort things for you.
qsort(hw_sucks, sizeof(int), blah blah blah, not sure of this, that's why I said man it. BAM! Your homework is done, and you're less of a n00b.
bouquet
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment