このディレクトリの索引 http://hibari.2ch.net/test/read.cgi/tech/1296387672/5 # [1] 授業単元:プログラミング # [2] 問題文(含コード&リンク):http://ime.nu/www.dotup.org/uploda/www.dotup.org1393065.txt.html # # 英語タイピング練習ソフトを作りたい.以下のような例文を入力し, # # その入力にかかった時間を計測し,一分間に何文字入力できる速度で # # あるかを出力するプログラムを作成せよ。 # # A bad workman quarrels with his tools. # Every man is the architect of his own fortune. # People who live in glass houses should not throw stones. # A bird in the hand is worth two in the bush. # As you make your bed, so you must lie in it. # # <注意> # 1.時間を測るためにtime関数,difftime関数を使用する # 2.上記の英文は,char *words[5] のようなポインタ配列の初期値として与えるか, # 別途ファイルに書いておき,そこから読み込むようにする. '英語タイピング練習ソフトを作りたい.以下のような例文を入力し,その入力にかかった時間を計測し,一分間に何文字入力できる速度であるかを出力する' :- write('タイプの入力を開始してください : '), get_char(_最初の文字), A is time, 例文を入力する([_最初の文字],1,_文字数), B is time _かかった時間 is B - A, _一分間に入力できる文字数 is truncate(_文字数 / _かかった時間 * 60), write_formatted('所要時間 = %t,一分間に入力できる文字数は %t です。\n',[_かかった時間,_一分間に入力できる文字数]). 例文を入力する(['.',t,i,' ',n,i|_],_文字数,_文字数) :- !. 例文を入力する(L1,_文字数1,_文字数) :- get_char(_文字2), _文字数2 is _文字数1 + 1, 例文を入力する([_文字2|L1],_文字数2,_文字数).