いろんな言語で宿題スレat TECH
いろんな言語で宿題スレ - 暇つぶし2ch120:デフォルトの名無しさん
09/06/09 13:32:07
>>112 6、
% Prolog

t112_6(X) :- get_integer(N),t112_6(N,[N],X).

t112_6(N,L,N) :- count(N,L,3).
t112_6(N,L,X) :- get_integer(M),t112_6(M,[M|L],X).

count(A,[],0).
count(A,[A|R],X) :- count(A,R,Y),X is Y+1.
count(A,[_|R],X) :- count(A,R,X).

get_integer(N) :- repeat,write('整数(0-9).改行 ? '),read(N),N>=0,N=<9,!.


次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch