BBC BASIC for Windows
« Dim array »

Welcome Guest. Please Login or Register.
Apr 5th, 2018, 10:55pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

If you require a dump of the post on your message board, please come to the support board and request it.


Thank you Conforums members.

BBC BASIC for Windows Resources
Online BBC BASIC for Windows documentation
BBC BASIC for Windows Beginners' Tutorial
BBC BASIC Home Page
BBC BASIC on Rosetta Code
BBC BASIC discussion group
BBC BASIC for Windows Programmers' Reference

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Dim array  (Read 560 times)
Wendell
New Member
Image


member is offline

Avatar




PM


Posts: 28
xx Dim array
« Thread started on: Mar 17th, 2014, 8:48pm »

num RND(10)

IS it possible to DIM "num" so that you get

EXP. num(1)=6 num(2)=5 num(3)=8 etc.


Ten deminsion with different values
User IP Logged

rtr
Guest
xx Re: Dim array
« Reply #1 on: Mar 17th, 2014, 9:23pm »

on Mar 17th, 2014, 8:48pm, Wendell wrote:
IS it possible to DIM "num" so that you get
EXP. num(1)=6 num(2)=5 num(3)=8 etc.
Ten deminsion with different values

Use the Knuth (or Fisher-Yates) shuffle:

Code:
      DIM num(10)
      FOR I% = 1 TO 10
        num(I%) = I%
      NEXT I%
      FOR I% = 10 TO 2 STEP -1
        SWAP num(I%),num(RND(I%))
      NEXT I%
      FOR I% = 1 TO 10
        PRINT "num("; I%; ") = "; num(I%)
      NEXT I% 

Richard.
User IP Logged

Wendell
New Member
Image


member is offline

Avatar




PM


Posts: 28
xx Re: Dim array
« Reply #2 on: Mar 17th, 2014, 9:53pm »

THANKS RICHARD . YOU DON'T KNOW HOW MUCH THAT HELP..i HOPE I DON'T ANNOY YOU GUYS.WORKING ON A PROJECT WITH MY GRANDKIDS. i DON'T THINK BILL GATES WOULD BE INTERESTED IN ME YET THOUGH. BUT I AM GETTING THERE
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls