% this is my attempt to write a shuffle routin % kris stewart juen 20, 1993 % i found c code from oak.oakland.edu in % /pub/msdos/math/shuffle.c by david wesson % clear %min = 0; %max = 7; min = input('enter the minimum integer '); max = input('enter the maximum integer '); count=max-min+1; % testing - initialize for i = 1 : count, z(i) = min + i - 1; end % z is overwritten during the shuffle zsave = z; % i keeps track of the output values from old c code i=1; for x=count:-1:1, % need random integer from 1 to x num = ceil(rand*x) ; % my outarray item corresponds to the printf(array[num]) outarray(i) = z(num); i=i+1; z(num) = z(x); end disp('The original list of numbers ') disp(zsave) disp('The shuffled list of numbers ') disp(outarray)