Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

10-card

math.randomseed(os.time())
local cards={} rev={}
for a=0,77,1 do
    cards[a]=a
    end
for i=0,77,1 do
    r1=math.random(0,77)
    r2=math.random(0,77)
    cards[r1],cards[r2]=cards[r2],cards[r1]
    rev[i]=math.random(0,1)
    end
for i=0,9,1 do
    if cards[i]>21 then
        local suit=(cards[i]-21)//14
        io.write((cards[i]-20-(14*suit)))
        if suit==0 then
            io.write("W")
        elseif suit==1 then
            io.write("C")
        elseif suit==2 then
            io.write("S")
        elseif suit==3 then
            io.write("P")
            end
    else
    io.write("M",cards[i])
    end
    if rev[i]==1 then
    io.write(" R")
    end
    io.write("\n")
end

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.