I have built a Table using HTML and would like to have a random number genereator, genereate numbers in each of the 5 boxes on the table with no duplicates between 1-50, I have a problem getting the numbers in each box on table, and creating no duplicate numbers - 3x5 square box - <table width="199" height="290" border="1">
-
<tr>
-
<td height="45"><div align="center">
-
<h2><strong>T</strong></h2>
-
</div></td>
-
<td> </td>
-
<td><div align="center"><a title= " prize 1">1</a></div></td>
-
</tr>
-
<tr>
-
<td height="47"><div align="center">
-
<h2><strong>A</strong></h2>
-
</div></td>
-
<td> </td>
-
<td><div align="center"><atitle="prize 2">2</a></div>
-
<div align="center"></div></td>
-
</tr>
-
<tr>
-
<td height="53"><div align="center">
-
<h2><strong>B</strong></h2>
-
</div></td>
-
<td> </td>
-
<td><div align="center"><a title="prize 3">3</a></div></td>
-
</tr>
-
<tr>
-
<td height="47"><div align="center">
-
<h2><strong>L</strong></h2>
-
</div></td>
-
<td> </td>
-
<td><div align="center"><a title="prize 4">4</a></div></td>
-
</tr>
-
<tr>
-
<td height="53"><div align="center">
-
<h2><strong>E</strong></h2>
-
</div></td>
-
<td> </td>
-
<td><div align="center"><a title="prize 5">5</a></div></td>
-
</tr>
-
</table>
-
<h3><strong>If your number appears in the square you win prizes 1-5</strong><br />
-
</h3>
I thought PHP would better, is C++ or Java better??
4 2088 Dormilich 8,658
Recognized Expert Moderator Expert
I see no benefit of one of the programming languages over the other, as long as your logic is correct.
I understand that much, i just am not sure how to write the code to randomly select the numbers, and place them in the select boxes on the table and not duplicate the numbers if and when it could happen. I will also need a button to start the random number selection.
Atli 5,058
Recognized Expert Expert
Well, if this is to be a web-page, PHP would probably be easiest to get started with. C++ is more of a desktop language, and Java is kind of... heavy.
Take a look at PHP's mt_rand function, and familiarize yourself with the while loop. If you don't want to get duplicate numbers from the random number generator (which kind of makes it... not random), then you will have to use a loop to select a new number over and over until you have a number that has not been selected before.
loop would probably work best, what I might end up doing is using numbers 1-5 and and the numbers will randomly be assigned with no duplicates. I guess random is used loosely, since I don't want the numbers to be duplicated. Any other ideas will be appreciated.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Alan Lee |
last post by:
Is there any way to set RAND_MAX in rand()? I am looking for a way to get a
random number between 1 and 1E9. So far I can't figure out how to do that.
any suggestions would be greatly appreciated.
|
by: Pat |
last post by:
I am looking for a good random number generator (such as Uniform, Normal
distributions). It is better if RNG is written in C++.
Thanks.
|
by: Joe |
last post by:
Hi, I have been working on some code that requires a high use of random
numbers within. Mostly I either have to either:
1) flip a coin i.e. 0 or 1, or
2) generate a double between 0 and 1.
I have utilised the following random number source code
http://www.agner.org/random/
What I have found is that there is a problem with seeding. The code
generates a seed based on time(0). I have found that I need to increment
|
by: Ben Pfaff |
last post by:
One issue that comes up fairly often around here is the poor
quality of the pseudo-random number generators supplied with many
C implementations. As a result, we have to recommend things like
using the high-order bits returned by rand() instead of the
low-order bits, avoiding using rand() for anything that wants
decently random numbers, not using rand() if you want more than
approx. UINT_MAX total different sequences, and so on.
So I...
|
by: Peteroid |
last post by:
I know how to use rand() to generate random POSITIVE-INTEGER numbers.
But, I'd like to generate a random DOUBLE number in the range of 0.0 to 1.0
with resolution of a double (i.e., every possible double value in the range
could come up with equal probability). I'd also like to be able to seed this
generator (e.g., via the clock) so that the same sequence of random values
don't come up every time.
Anybody have an easy and fast...
| |
by: L33VaNcL33F |
last post by:
I like to make a javascript that generate random number from the range number within : (10016486 and 99999985).
the number always + 22423 that begin from 10016486 and end at 99999985
Example random result from generate button :
10016486 + 22423 = 10038909
10038909 + 22423 = 10061332 and so on, maximum to 99999985
or if somebody can convert below c++ code to working javascript/html random number generator.
#include <cstdlib>
#include...
|
by: jason.cipriani |
last post by:
I am looking for a random number generator implementation with the
following requirements:
- Thread-safe, re-entrant.
- Produces consistently reproducible sequences of psuedo-random
numbers given a seed.
- Relatively uniform, does not have to be perfect.
The application is not a security or statistics application, the
quality of numbers is not a priority although a fairly uniform
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |