亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Lua中算術(shù)運(yùn)算符的使用示例

 更新時(shí)間:2015年05月27日 12:05:10   投稿:goldensun  
這篇文章主要介紹了Lua中算術(shù)運(yùn)算符的使用示例,是Lua入門學(xué)習(xí)中的基礎(chǔ)知識(shí),需要的朋友可以參考下

下表列出了所有的Lua語(yǔ)言支持的算術(shù)運(yùn)算符。假設(shè)變量A持有10和變量B持有20,則:

2015527120458107.jpg (635×320)

 例子

試試下面的例子就明白了所有的Lua編程語(yǔ)言提供了算術(shù)運(yùn)算符:

復(fù)制代碼 代碼如下:
a = 21
b = 10
c = a + b
print("Line 1 - Value of c is ", c )
c = a - b
print("Line 2 - Value of c is ", c )
c = a * b
print("Line 3 - Value of c is ", c )
c = a / b
print("Line 4 - Value of c is ", c )
c = a % b
print("Line 5 - Value of c is ", c )
c = a^2
print("Line 6 - Value of c is ", c )
c = -a
print("Line 7 - Value of c is ", c )

當(dāng)執(zhí)行上面的程序,它會(huì)產(chǎn)生以下結(jié)果:

復(fù)制代碼 代碼如下:
Line 1 - Value of c is  31
Line 2 - Value of c is  11
Line 3 - Value of c is  210
Line 4 - Value of c is  2.1
Line 5 - Value of c is  1
Line 6 - Value of c is  441
Line 7 - Value of c is  -21

相關(guān)文章

最新評(píng)論