我一直在使用C++中的Rabin-Karp字符串匹配函数,但我没有得到任何结果.我有一种感觉,我没有正确计算一些值,但我不知道哪一个.
原型
void rabinKarp(string sequence, string pattern, int d, int q);
Run Code Online (Sandbox Code Playgroud)
功能实现
void rabinKarp(string sequence, string pattern, int d, int q)
{
//d is the |?|
//q is the prime number to use to lessen spurious hits
int n = sequence.length(); //Length of the sequence
int m = pattern.length(); //Length of the pattern
double temp = static_cast<double> (m - 1.0);
double temp2 = pow(static_cast<double> (d), temp); //Exponentiate d
int h = (static_cast<int>(temp2)) % q; //High Order Position of an m-digit …Run Code Online (Sandbox Code Playgroud) 我一直在测试clang-llvm,看看我的学校IT部门是否值得将它添加到我们学生编程的机器上.对于我们的所有作业,我们需要使用编译g++ -Wall -W -pedantic-errors *.cpp,所以我只是将命令转换为clang++ -Wall -W -pedantic-errors.我得到了一些我没想到的输出:
Attempting to compile...
In file included from test_library.cpp:6:
In file included from ./test_library.h:64:
In file included from ./library.h:167:
./library.hpp:20:23: warning: unused variable 'e' [-Wunused-variable]
catch(Exception & e)
^
Run Code Online (Sandbox Code Playgroud)
而GCC编译器没有给出catch块中未使用的变量的错误.有什么我可以这样做,以便Clang不会对try/catch块中未使用的变量感到不满,同时保持命令类似于g ++吗?
Clang-LLVM(v2.7)GNU GCC(v4.4.4)Fedora 13