![]() |
Rand() function seeded srand(time(0)
I know how to make a bubble sort and the exchange sort but I do not know how to generate a small arrays of dimension 20, such that the entries are random positive integers less than 100. I am also not sure if I can combine the bubble, exchange and sort the random array of integers. Heres what I have so far:
Bubble Sort: Code:
#include <stdio.h> |
great... can someone translate ??? babelfish doesnt support it.
|
Quote:
Deadlock, I'm not sure what you're askinng, but if you want it less than 100, just use an if statement to limit it, and save that value to an array. |
Sorry, I'm not really sure what you asked either. I looked at your code, and the only thing I could comprehend from your question that makes sense would be that you want to fill up an array of, say, 20 slots with random integers frm 1-100, in order to sort them afterwards or whatnot.
Well, I see numbers[i]=rand(); rand()%100 will give a random integer from 0 to 99, so use this line to get 1-100 inputted into a slot of your array: numbers[i]=rand()%100+1; Not sure if that's what you meant. It's been too long since I dealt with this. I recall writing a new randomizer function way back that took a min and max parameter, kind of like the PHP function. Not that it really matters, it just takes some basic math skills to figure out your range. Now that I see your other post about QuickSort, my answer feels too basic. |
I am to post to use rand() (seeded with either srand(time(0)) or with randomize(), to generate a small arrays of dimsion 20, such that the entries are random positive integers less than 100. Then I have make sure to implement the bubble sort and the exchange sort and sort the random array of integers.
|
Can anyone help me I still don't get it?
|
Translation
Quote:
|
All times are GMT -6. The time now is 03:28 AM. |
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
This site is best seen with your eyes open.