Skip to content

Instantly share code, notes, and snippets.

View kaworun's full-sized avatar

Kenta Oki kaworun

View GitHub Profile
year = io.read()
function junishi(y)
data = {"申","酉","戌","亥","子","丑","寅","卯","辰","巳","午","未"}
return print(data[year % 12])
end
junishi(year)
n = io.read()
function hanbetu(n)
if(n % 2 == 0) then print "even"
else print "odd"
end
end
hanbetu(n)
cm = io.write()
function convert(cm)
h = cm / 13
return print(string.format("ハンバーガー %.2f個分 くらいかな?", h))
end
convert(cm)
#include <stdio.h>
int main(void) {
int i, j;
for (i=1; i<=9; i++) {
for (j = 1; j <=9; j++) {
printf("%d * %d = %d\n", i, j, i*j);
}
puts("");
}
#include <stdio.h>
int main(void) {
printf("Hello World!");
return 0;
}
h = io.read(*d)
w = io.read(*d)
function measurement(w, h)
bmi = w / (h * h)
print(string.format("%.2f", bmi))
if bmi < 18.5 then
print "低体重"
elseif 18.5 <= bmi or bmi > 25 then
print "普通"
for i = 1, 9 do
for j = 1, 9 do
io.write(string.format("%-3d", i * j))
end
print ""
end
function second()
second = 86400 - (os.date("%H") * 3600 + os.date("%M") * 60 + os.date("%S") * 1)
return print(second)
end
print "明日までの時間(秒)"
second()
@kaworun
kaworun / func_sum2.lua
Created February 2, 2013 16:56
四則演算。
x = io.read()
y = io.read()
z = io.read()
function sum2(x, y, z)
if z == "+" then
print(x .. z .. y .. "=" .. x + y)
elseif z == "-" then
print(x .. z .. y .. "=" .. x - y)
elseif z == "*" then
@kaworun
kaworun / omikuzi_lua.lua
Created February 2, 2013 11:40
Lua でおみくじ。
function omikuzi()
t = {"大吉","中吉","小吉", "吉", "凶", "大凶"}
i = math.random(#t)
print(t[i])
end
omikuzi()