You should ask for string before you reverse it, cin >> x;
should be before you use std::reverse
, because it's empty.
This line
cout>>LCS(x,y,x.length(),y.length());
has a typo, it should be cout << ...
.
std::reverse
does not return the reversed string, it reverses it in place, you can't assign it to another std::string
. This is the source of the error you show.
The string x
will be reversed.
You may want something like:
string x;
string y;
cin >> x; //input x
y = x; //make a copy of x
reverse(y.begin(), y.end()); // reverse y
cout << LCS(x, y, x.length(), y.length());
Other notes:
The C++ standard does not allow for variable length arrays, int t[n + 1][m + 1];
is not valid C++, though some compilers allow its use.
using namespace std;
is not recommended.
As is not #include <bits/stdc++.h>
.