| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
HELP!! 为啥说 runtime error 啊?(1458)自己运行时通过了的。。。郁闷#include <iostream>
#include <string>
#include <vector>
using namespace std;
int _length[2][100];
struct Length
{
int* operator [](int i)
{
return _length[i%2];
}
} length;
int judge(string A, string B)
{
int m = A.size();
int n = B.size();
for (int i = 0; i <= m; i++)
for (int j = 0; j <= n ;j++)
{
if (i == 0 || j == 0)
length[i][j] = 0;
else if (A[i-1] == B[j-1])
{
length[i][j] = length[i-1][j-1] + 1;
}
else
{
if (length[i-1][j] <= length[i][j-1])
length[i][j] = length[i][j-1];
else
length[i][j] = length[i-1][j];
}
}
return length[m][n];
}
int main()
{
string A, B;
while (cin >> A, cin >> B)
{
cout << judge(A, B) << endl;
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator