Solved

input random elements to an array

Posted on 1998-08-06
3
219 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
ID: 1217273
Edited text of question
0
 

Author Comment

by:gudbgud
ID: 1217274
Edited text of question
0
 
LVL 2

Accepted Solution

by:
vx earned 50 total points
ID: 1217275
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Some of the SEO trends we might expect in 2017.
Most MSPs worth their salt are already offering cybersecurity to their customers. But cybersecurity as a service is wide encompassing and can mean many things.  So where are MSPs falling in this spectrum?
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

861 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