2017-10-13 10 views

答えて

1
Program RandomString; 

// Get a random character from A to Z 
function GetRandomCharacter: char; 
begin 
    // Use A random value from 0 to 25 and add that to A 
    Result := 'A'; 
    Inc(Result, Random(26)); 
end; 

// Get a random string of characters from A to Z 
// with a length from 8 to 24 characters 
function GetRandomString: string; 
var 
    Length: Integer; 
    I: Integer; 
begin 
    // Get a random length to use from 8 to 24 
    Length:= 8 + Random(17); 

    // Create a string of random characters with the desired length 
    Result := ''; 
    for I:= 1 to Length do 
    begin 
    Result := Result + GetRandomCharacter; 
    end; 
end; 

begin 
    // Execute Randomize only once in the application 
    Randomize; 

    Writeln(GetRandomString); 
end. 
関連する問題