2017-10-17 2 views
-1

テキストファイルの入力は、次の形式です。ここで、5は考慮する行の数、1は1番目に多い単語、8番目の単語が8番目に多い単語です。私の質問は、この数値を変数に読み込む方法です。テキストファイルからいくつかの行を読み込み、C++を使用してそこにあるすべての単語の頻度を表示したい

入力テキストファイルは:

5 1 8 

the classical latin alphabet also known as the roman alphabet is a writing system which evolved 

from the cumaean version of the greek alphabet the cumaean script was descended from the 

phoenician alphabet the cumaean alphabet was adopted and modified by the etruscans who 

ruled early rome the etruscan alphabet was in turn adopted and further modified by the 

ancient romans to write the latin language 
+1

使用する言語を知っておくことが重要です。 http://idownvotedbecau.se/noresearch/ – tilz0R

+0

言語は上記の質問のタイトルでC++です。 –

+0

C言語にタグが付けられたのはなぜですか? – tilz0R

答えて

0

私はおそらくあなたがテキストでその単語を見つけるたびにstd::map<string, int>を作成し、各単語の値をインクリメントします。各単語について、そのキーの値がmapに存在するかどうかを確認し、そうでない場合は1を割り当て、それ以外の場合は単に値を1だけ増やします。

関連する問題