ok now, the code that randomizes the data ia working. Now, How do I make sure that the names are not repeated?
Note: continuation from this thread 5 1034
ok now, the code that randomizes the data ia working. Now, How do I make sure that the names are not repeated?
Note: continuation from this thread
Two techniques come to mind... - Build an array of the ones which have been used, and check against that array before using each one.
- Somehow flag those in the original array which have been used, so you can skip over them when looking for the next one.
Actually, these are really just two slight variations on the same idea.
Two techniques come to mind...- Build an array of the ones which have been used, and check against that array before using each one.
- Somehow flag those in the original array which have been used, so you can skip over them when looking for the next one.
Actually, these are really just two slight variations on the same idea.
i have no idea how to do that but thanxs anyway
if you can explain plus i need to know how to record quiz results
i have no idea how to do that but thanxs anyway
if you can explain plus i need to know how to record quiz results
I'd rather not explain in too much detail, as it's more beneficial if you think your way through it.
Basically though, I believe you know how to create an array and place values in it, as you are doing that already with your list of presidents. So, you set up another array with the same number of elements, but no values placed in it yet. Each time you pick a president, you copy it to the next available place in the second array. And before picking each president, you loop through the second array to make sure it isn't already there. If it is, choose again.
The other option works more or less the same, except that instead of copying each name into the second array, you simple set a flag (typically Boolean type) to indicate that entry number n has been used.
I'd rather not explain in too much detail, as it's more beneficial if you think your way through it.
Basically though, I believe you know how to create an array and place values in it, as you are doing that already with your list of presidents. So, you set up another array with the same number of elements, but no values placed in it yet. Each time you pick a president, you copy it to the next available place in the second array. And before picking each president, you loop through the second array to make sure it isn't already there. If it is, choose again.
The other option works more or less the same, except that instead of copying each name into the second array, you simple set a flag (typically Boolean type) to indicate that entry number n has been used.
ok thank you im getting it
do you knw how to have them type in the number of the president and it needs to record the answer and check if it is correct or incorrect and tell them at the end what they scored
ok thank you im getting it
do you knw how to have them type in the number of the president and it needs to record the answer and check if it is correct or incorrect and tell them at the end what they scored
Most likely by putting entries in another array or two, then reading them back at the end. Play around with it, and see what you can come up with.
As an idea, you could set up an array of type Boolean, in which True represent a correct answer, and False an incorrect one. The index is the question number. (Or you might want to use a different data type with more than two possible values, so you can tell whether they have been set yet).
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Thomas Lotze |
last post by:
Hi,
I'm trying to figure out what is the most pythonic way to interact with
a generator.
The task I'm trying to accomplish is writing a PDF tokenizer, and I want
to implement it as a Python...
|
by: JNY |
last post by:
I am using random to generate random numbers, thus:
int x,y;
for (y = 0;y < 5;y++)
{
x = random(50);
cout << x;
}
|
by: TaTonka |
last post by:
hi!
how can i manage it (html or jscript with css) that everytime a user loads
or refreshes a page, the page has a new bgcolor.
i want to put it in a single file, so that all my pages have the...
|
by: Greg Strong |
last post by:
Hello All,
Is it possible to create multiple random numbers in a query where
there are numerous records?
I've created a custom function. When I use it in a query it creates
the same random...
|
by: Leon |
last post by:
I know by default the random number generator use the time, but what is the
best seed I can used in my web application?
The Program generate 6 unique random numbers and load each of them in a...
|
by: GaryDean |
last post by:
We have been noticing that questions on vs.2005/2.0 don't appear to get much
in answers so I'm reposting some questions posted by some of the programmers
here in our organization that never got...
|
by: aspnoob |
last post by:
hello i just started off with asp.net , needed some help on how to display
the state of checkboxes from a SQL database.
my database table has the following format
seat.dbo ( db design)
(...
|
by: tshad |
last post by:
I have a page that I am getting a username and password as a random number
(2 letters, one number and 4 more letters)
I have 2 functions I call:
*************************************************...
|
by: akineko |
last post by:
Hi everyone,
First of all, I'm not an expert on Javascript. Please forgive me if my
question is pointless.
I want control a hardware device using a Web browser.
I created a page which has a...
|
by: Brit |
last post by:
I have an ASP file that retrieves names from an Access database for 4 different categories of membership, which the visitor to the page selects (corporate, institutional, regular, or student). The...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
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,...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
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,...
| |