“Daftar Shuffle dan Cetak” Kode Jawaban

Daftar Python Shuffle

import random
number_list = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70]
print ("Original list : ",  number_list)

random.shuffle(number_list) #shuffle method
print ("List after shuffle  : ",  number_list)
Kodi4444

Daftar Shuffle dan Cetak

Function SortIntegerList : String;
var a : Array of cardinal;
    i,j : integer;
      t : cardinal;
 Letter : String[1];
   AStr : String;
begin
// USING the simple Satolo cycle to unsort/scramble a numeric string
// Modified to scramble the letters of the Alphabet
  randomize;
  a := [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26];
  i := length(a);
  while i > 0 do
    begin
     dec(i);
     j := randomrange(Low(a),i);
     t := a[i];
     a[i] := a[j];
     a[j] := t;
     Letter := Chr(a[i]+64);
     AStr := AStr + Letter;
    end;
    Result := AStr;
end;

// How to use
Procedure ButtonClick(Sender: TOBject);
begin
  ShowMessage('Scrambled String '+AStr);
end;
JerBear

Jawaban yang mirip dengan “Daftar Shuffle dan Cetak”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya