0

したがって、これは、辞書ファイル内の特定の単語を見つけるために文字のマトリックスを反復処理する方法です。現在の問題は、以下に示す悪いアクセスです....これを引き起こしているのは、d2 = 100万のようで、lも数十万の値に等しい....しかし、私の限界は明らかにそれに近くさえありません. .....

void Puzzle:: algorithm2(){
    int numberofwords = 0;
    for (int r = 0; r<Rows; r++) {
        for (int c = 0; c<Columns; c++){
            for (int d1 = -1; d1<=1; d1++){
                for (int d2 = -1; d2<=1; d2++){
                    //42 ~ 30(2)^0.5
                    for (int l = dictionary.getminlength(); l<30; l++) {
                        if (d1==d2==0){
                            continue;
                        }
                        else if ((r+(d1*l))>30||(c+(d2*l))>30||(c+(d2*l))<0||(r+(d1*l))<0){
                            break;
                        }
                        else{
                            string tempword = "";
                            for (int p = 0; p<l+1; p++) {
                                tempword[p] = TheBoard[r+(d1*p)][c+(d2*p)];//badacces
                                if(dictionary.BinarySearch(tempword)){
                                    cout << "Found " << tempword << " at (" << r << "," << c << ") to (" << r+d1*(int)tempword.length() << "," << c+d2*(int)tempword.length() << ")" << endl;
                                    numberofwords++;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    cout << numberofwords << "words" << endl;
}
4

0 に答える 0