07_STD_MP: weitere Vergleiche in Arbeit
Signed-off-by: Johannes Theiner <j.theiner@live.de>
This commit is contained in:
parent
65ea034511
commit
789099fbde
|
@ -18,6 +18,7 @@ struct BinaryOctet {
|
|||
};
|
||||
|
||||
int main() {
|
||||
std::srand(static_cast<unsigned int>(std::time(0)));
|
||||
int array[41];
|
||||
|
||||
std::default_random_engine generator;
|
||||
|
@ -34,6 +35,7 @@ int main() {
|
|||
|
||||
//TODO: Punkte gleichmässig verteilen
|
||||
int stringSimilarity(std::string string1, std::string string2) {
|
||||
std::string alphabet = "abcdefghijklmnopqrstuvwxyzäöü";
|
||||
//wenn gleicher String, gleich 100 Punkte geben, spart den Rest
|
||||
if(string1 == string2) return 100;
|
||||
int points = 0;
|
||||
|
@ -60,15 +62,22 @@ int stringSimilarity(std::string string1, std::string string2) {
|
|||
|
||||
int equalCharCount = 0;
|
||||
for(std::pair<char, int> c : characterCount) {
|
||||
//gleiche Anzahl an gleichen Zeichen in beiden überprüfen
|
||||
int charCount = c.second / 2;
|
||||
if(charCount == string1map[c.first] && charCount == string2map[c.first]) {
|
||||
equalCharCount++;
|
||||
}
|
||||
|
||||
if(isupper(c.first)) c.first = tolower(c.first);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//gleiche Anzahl an gleichen Zeichen +10 Punkte
|
||||
if(equalCharCount == characterCount.size()) points += 10;
|
||||
|
||||
|
||||
|
||||
//TODO: Punkte für gleiche Buchstaben und gleiche Buchstaben Anzahl vergeben
|
||||
|
||||
|
||||
|
@ -98,6 +107,5 @@ void unittest_stringSimilarity() {
|
|||
"At vero eos et accusam et justo duo dolores "
|
||||
"et ea rebum. Stet clita kasd gubergren, "
|
||||
"no sea takimata sanctus est Lorem ipsum "
|
||||
"dolor sit amet.",
|
||||
"Lorem ipsum") << std::endl;
|
||||
"dolor sit amet.", "Lorem ipsum") << std::endl;
|
||||
}
|
Loading…
Reference in New Issue