|
||||||
| General Programming Non language specific, Assembly, Linux/Unix, Mac and anything not covered in other topics. Talk about Programming Theory here. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
Hi, I need to write a random generator for company use. All I need is a site to display a random phrase from a preset list of phrases.
Does anyone already have code for it? Thanks! |
| Sponsored Links |
|
|
|
|||||
|
If you really want a good generator, the only thing you can use is mother earth. Put up some engine, that gets wind speed, and calculate from that. The wind speed is very random, and if you combines it with time, it will be even more random. Instead of wind, you could use something else, like sound, or everything else.
Another, and easier way, is to look at this: Eternally Confuzzled - Using rand() |
|
|||||
|
For what you're describing, you just need to use the random number generation provided by most languages to generate an integer, and display the corresponding phrase (possibly stored in an array).
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum Programming is a branch of mathematics. |
|
|||||
|
Like WingedPanter said:
Have your phrases stored in an array. Use the random number generator provided with your language to pick an array index at random. Display the phrase at that index. Random number generators usualy give you a random double-precision number between 0 and 1, so you would do something like: Code:
phrase = phrase_array[(int)(random()*size_of_array)];
__________________
My fun, friendly online games website: Cygnet Games My Squidoo page on Cygnet Games. |
|
|||||
|
Quote:
Here is an easy way to do it in php: Generating Random Numbers using PHP |
| Sponsored Links |
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Random Generator of Unequal Numbers | Paradine | PHP Tutorials | 0 | 08-26-2007 03:11 PM |
| Floating Point random number generator | Paradine | PHP Tutorials | 0 | 08-26-2007 03:09 PM |
| The latest program i wrote!! | A.N.H | Java Help | 1 | 04-30-2007 03:36 PM |
| Need help w/ word count program (ASAP) | siren | C and C++ | 1 | 04-23-2007 09:14 AM |
| WingedPanther | ........ | 2753.6 |
| Xav | ........ | 2704 |
| Brandon W | ........ | 1702.32 |
| John | ........ | 1207.73 |
| marwex89 | ........ | 1175.24 |
| morefood2001 | ........ | 966.05 |
| dcs | ........ | 655.75 |
| Steve.L | ........ | 475.59 |
| orjan | ........ | 418.58 |
| Aereshaa | ........ | 383.54 |
Goal: 100,000 Posts
Complete: 98%