#include <iostream>
#include <stdio.h>
#include <string>
#define MAX_LENGTH 1001
using namespace std;
char a[MAX_LENGTH];
char b[MAX_LENGTH];
int DP[MAX_LENGTH][MAX_LENGTH];
int max(int a, int b){
return a > b ? a : b;
}
int main(){
cin >> a;
cin >> b;
int len1 = strlen(a);
int len2 = strlen(b);
int Max = 0;
for (int i = 1; i <= len2; i++){
for (int j = 1; j <= len1; j++){
if (a[j-1] == b[i-1]){
DP[i][j] = DP[i-1][j-1] + 1;
}
else{
DP[i][j] = max(DP[i-1][j], DP[i][j - 1]);
if (Max < DP[i][j]) Max = DP[i][j];
}
}
}
cout << Max;
//system("pause");
return 0;
}
이것도 컴파일 에러가 나네요. .ㅠ
skyinyour 6년 전
런타임 에러라면 배열의 인덱스를 살펴볼텐데.. 컴파일 에러는 어디서 나는건가요?? ㅠ
VS 2013 에서는 아무 문제가 없습니다 ㅠㅠ