Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

need LCS in mips assembly, already have C++

HI everyone, i need to have the Longest common substring code in mips assembly. later on i will write an assembler for that. now I have the c++ code, but have no idea what the assembly code will be


#include

#include



using namespace std;

int main () {



string first, second, lcsub, max;



cout << "Enter two words" << endl;

cin >> first >> second;

for (int i=0; i < first.length(); i++)

for (int j=0; j < second.length(); j++)

for (int k=1; k <= first.length() && k <= second.length(); k++){

if (first.substr(i,k) == second.substr(j,k)){

lcsub = first.substr(i,k);

}

else{

if (lcsub.length() > max.length())

max=lcsub;

lcsub="";

}

}

if (lcsub.length() > max.length())
max=lcsub;

lcsub="";


cout << "Longest Common Substring: " << max << endl;

return 0;
}

Sign In or Register to comment.