it gets rte.
but i can't understand.
plz elp.
thanks...
Code: Select all
thank you.
solved now.thanks again
Moderator: Board moderators
Code: Select all
thank you.
solved now.thanks again
Code: Select all
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
char from[21], to[21];
int array[21][21];
void med(int f, int t) {
if(f<0 || t < 0) return;
med(f - 1, t);
for(int t1 = 0; t1 <= t; t1++) {
if( t1 == 0) {
array[f][t1] = f;
} else if (f == 0) {
array[f][t1] = t1;
} else {
int d = (t1-1 >= 0 && f-1 >=0)? array[f-1][t1-1] : -1;
int u = (t1-1 >= 0) ? array[f][t1-1] + 1 : -1;
int b = (f-1 >= 0) ? array[f-1][t1] + 1 : -1;
if(from[f-1] != to[t1-1]) {
d++;
}
int v = d;
if((u < v && u != 0) || v == -1) {
v = u;
}
if((b < v && b != 0) || v == -1) {
v = b;
}
array[f][t1] = v;
}
}
}
typedef vector<string> dictionary;
dictionary dict;
int main(){
char word[15];
while(1) {
scanf("%s", word);
if(strcmp("#",word) == 0) break;
dict.push_back(string(word));
}
while(1) {
scanf("%s", from);
if(strcmp(from, "#") == 0) break;
printf("%s", from);
if(find(dict.begin(), dict.end(), from) != dict.end()) {
printf(" is correct\n");
} else {
printf(":");
for(dictionary::iterator i = dict.begin(); i != dict.end(); i++) {
strncpy(to,(*i).c_str(),20);
med(strlen(from),strlen(to));
if(array[strlen(from)][strlen(to)] ==1)
printf(" %s", (*i).c_str());
}
printf("\n");
}
}
}
Code: Select all
code removed
Code: Select all
Now I got AC
Code: Select all
while(true){}
Code: Select all
1
hqghumeaylnlfd
fi
cvscxggbwkfn
#
hqghumeaylnlf
i
f
vscxggbwkfn
#
Code: Select all
hqghumeaylnlf: hqghumeaylnlfd
i: fi
f: fi
vscxggbwkfn: cvscxggbwkfn