int main(){ #ifdef LOCAL_TEST std::ifstream in("input.txt",std::ifstream::in); #else std::istream& in=std::cin; #endif std::string line1; std::string line2; for(;;){ if(line1.empty()) { std::getline(in,line1); if(!in || line1.empty()) break; continue; } else std::getline(in,line2); if(!in || line2.empty()) break; std::cout<<lcsLength(line1,line2)<<"\n"; line1.clear(); } #ifdef LOCAL_TEST in.close(); #endif return 0; }
static void diff(QList<QByteArray> a, QList<QByteArray> b) { QList<Unit*> *res = diffHelper(lcsLength(a, b), a, b, a.size(), b.size()); for (int i = 0; i < res->size(); i++) { Unit *unit = res->at(i); unit->print(a, b); delete(unit); } delete(res); }
void main() { string s1, s2; cout << "Enter the first string: "; getline(cin, s1); cout << "Enter the second string: "; getline(cin, s2); printLCS(lcsLength(s1, s2), s1, s1.length(), s2.length()); cout << endl; }
void HashClass::cercaAlternativa(HashItem *termine){ int lcs; int max =0; std::list <HashItem> parola; //In questo ciclo trovo tutte le parole con la max sottosequenza for (int i=0; i< TABLE_SIZE; i++) { if (this->hashTable[i]!=NULL) { lcs = lcsLength(termine->getTermine(), hashTable[i]->getTermine()); //std::cout<<"\nLCS VALE:"<<lcs<<"\n"; if (max<lcs) { max=lcs; } } } //Aggiungo tutte le parola con la max sotto sequenza in una lista for (int i=0; i<TABLE_SIZE; i++) { if (this->hashTable[i]!=NULL) { lcs = lcsLength(termine->getTermine(), hashTable[i]->getTermine()); if (lcs == max) { parola.push_back(*hashTable[i]); } } } //Stampo tutti i possibili termi che l'utete forse cercava std::cout<<"\nForse cercavi:\n"; std::list<HashItem>::iterator iterator =parola.begin(); while (iterator!=parola.end() ){ std::cout<<iterator->getTermine()<<" : "<<iterator->getSignificato()<<"\n"; iterator++; } }