-1

簡単な質問で皆さんを悩ませて申し訳ありませんが、私は C++ が初めてで、どうすればよいかわかりません。そのため、単語検索と検索対象の単語のリストを含む 2 つの txt ファイルを読み取り、結果を別の txt ファイルに表示する C++ のフレームワークが提供されました。フレームワークを完成させようとしていますが、プログラムが 8 つの方向すべてを正確にチェックする方法や、システムが辞書ファイル内の単語を単語検索と比較し、一致する単語を results.txt ファイルに入れる方法がわかりません。以下にフレームワークを添付しました。開始方法に関する情報やアドバイスをいただければ幸いです。

dictionary.txt 
ABSEIL
BIKE
PIXEL
RESIGHTS
YARDWORKS

wordsearch.txt 
S T H G I S E R B
G K L L B X D I E
K P R H I M K L D
T G Y O L E X I P
B A P T W H T E J
T Q U D X D W S F
V M V S H L R B A
H Q L B C K S A Y
R D G B F J P Q Y


Wordsearch.h 
#pragma once

#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <Windows.h>

using namespace std;

class WordSearch
{
 public:
WordSearch();
~WordSearch();

bool ReadPuzzle();
bool ReadDictionary();
bool SolvePuzzleWithDictionary();

void WriteResults(string fileName);

private:
LARGE_INTEGER start, end, frequency;
const int NUMBER_OF_RUNS;
const string PUZZLE_NAME;
const string DICTIONARY_NAME;
};


Wordsearch.cpp 
 #include "WordSearch.h"
 #include <algorithm>
 #include <iterator>
 #include <iostream>
 #include <iomanip>

using namespace std;

WordSearch::WordSearch() : NUMBER_OF_RUNS(500), PUZZLE_NAME("wordsearch_grid.txt"), DICTIONARY_NAME("dictionary.txt")
{
}

WordSearch::~WordSearch()
{
}

bool WordSearch::ReadPuzzle()
{
cout << endl << "ReadPuzzle() has NOT been implemented" << endl;
return true;
}

bool WordSearch::ReadDictionary()
{
cout << endl << "ReadDictionary() has NOT been implemented" << endl;
return true;
}

bool WordSearch::SolvePuzzleWithDictionary() {
cout << endl << "SolvePuzzleWithDictionary() has NOT been implemented" << endl;
double timeTakenInSeconds;
QueryPerformanceFrequency(&frequency);
QueryPerformanceCounter(&start);

for (int n = 0; n < NUMBER_OF_RUNS; ++n) {
    // Add solving code here!
}

QueryPerformanceCounter(&end);
timeTakenInSeconds = (end.QuadPart - start.QuadPart) / (double)(frequency.QuadPart*NUMBER_OF_RUNS);

cout << fixed << setprecision(10) << "SolvePuzzleWithDictionary() - " << timeTakenInSeconds << " seconds" << endl;
return false;
}

void WordSearch::WriteResults(string fileName) {
cout << "WriteResults() has NOT been implemented" << endl;
}
4

1 に答える 1