Solved

input random elements to an array

Posted on 1998-08-06
3
203 Views
Last Modified: 2010-04-16
If I have an array or an type of all "char" ,  how can I  input a random result from that array into a smallar array, f.x.  array [1..5] of Char;
, or better, a few arrays of that same type.
0
Comment
Question by:gudbgud
  • 2
3 Comments
 

Author Comment

by:gudbgud
Comment Utility
Edited text of question
0
 

Author Comment

by:gudbgud
Comment Utility
Edited text of question
0
 
LVL 2

Accepted Solution

by:
vx earned 50 total points
Comment Utility
I coded a little program for you; I think it does what you mean:

Var FirstArray: Array[1..100] of Char;          { The whole array }
    SecArray:   Array[1..5] of Char;            { The new array }
    Counter:    Integer;                        { A random number }

Begin
  Repeat
    Randomize;                                  { Initialize random sequence }
    Counter := Random(100)+1;                   { Create a random number and add one to that }
                                                { Random generates a number from 0<=x<100 }
                                                { The array shouldn't be addresses with 0, so add one }
    SecArray := FirstArray[Counter];            { Copy a number from the first array to the second }
  Until KeyPressed;
End.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

HOW TO: Upload an ISO image to a VMware datastore for use with VMware vSphere Hypervisor 6.5 (ESXi 6.5) using the vSphere Host Client, and checking its MD5 checksum signature is correct.  It's a good idea to compare checksums, because many installat…
Veeam Backup & Replication has added a new integration – Veeam Backup for Microsoft Office 365.  In this blog, we will discuss how you can benefit from Office 365 email backup with the Veeam’s new product and try to shed some light on the needs and …
This video discusses moving either the default database or any database to a new volume.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now