沢渡 みかげ #133(2007/07/04 15:15 GMT) [ Erlang ] Rating0/0=0.00
erl -noshell -eval 'pyramid:pyramid(4), halt().' のように実行.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
-module(pyramid). -export([pyramid/1]). pyramid(N) -> pyramid(N, 1). pyramid(Max, Row) when Max < Row -> ok; pyramid(Max, Row) -> write(" ", Max - Row), write("*", Row * 2 - 1), io:put_chars("\n"), pyramid(Max, Row + 1). write(_String, 0) -> ok; write(String, Repeat) -> io:put_chars(String), write(String, Repeat - 1).
Rating0/0=0.00-0+
[ reply ]
沢渡 みかげ
#133()
[
Erlang
]
Rating0/0=0.00
-module(pyramid). -export([pyramid/1]). pyramid(N) -> pyramid(N, 1). pyramid(Max, Row) when Max < Row -> ok; pyramid(Max, Row) -> write(" ", Max - Row), write("*", Row * 2 - 1), io:put_chars("\n"), pyramid(Max, Row + 1). write(_String, 0) -> ok; write(String, Repeat) -> io:put_chars(String), write(String, Repeat - 1).Rating0/0=0.00-0+
[ reply ]