function PrintLower(str)
print(str:lower())
end
function MergeAndSort(array1, array2)
local array = {}
for _, elem in ipairs(array1) do
table.insert(array, elem)
end
for _, elem in ipairs(array2) do
table.insert(array, elem)
end
table.sort(array)
for _, elem in ipairs(array) do
io.write(elem, ', ')
end
end
function PrintDigitsAndReverse(num)
local digits = math.ceil(math.log(num)/math.log(10))
print("The digit of " .. num .. " is " .. digits)
print("The reversed number is ")
while num >0 do
local lastDigit = num % 10
io.write(lastDigit)
num = (num - lastDigit) / 10
end
end
2.function list(data, n)
local str = ""
for i = 1, #data do
if data[i] >n then
str = str .. data[i] .. ","
end
end
return str
end
3.
function odds(data)
local str = ""
for i = 1, #data do
if data[i] % 2 == 1 then
str = str .. data[i]
end
end
return str
end
4.
function factorial(n)
local num = 1
for i = 1, n do
num = num * i
end
return num
end
5.
function dividers(n)
local str = "
for i = 1, math.floor(n / 2) do
if n % i == 0 then
str = str .. i
end
end
return str
end
if vip then实际花费金钱 = 商品总价*0.8
end
if 商品总价<100 then
实际花费金钱 = 商品总价*0.9
end
else
if 商品总价>=100 then
实际花费金钱=商品总价*0.9
end
if 商品总价<100 then
实际花费金钱=商品总价
end
折扣额 = 商品总价-实际花费金钱
最终付款的金额 = 实际花费金钱
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)