From f7257a2cc8d0350dfea996a9edcaa10fc42842eb Mon Sep 17 00:00:00 2001 From: Johannes Theiner Date: Tue, 2 Oct 2018 11:26:26 +0200 Subject: [PATCH] =?UTF-8?q?07=5FSTD=5FMP:=20Fehler=20bei=20komplett=20unte?= =?UTF-8?q?rschiedlichen=20Strings=20behoben,=20neuen=20beim=20Z=C3=A4hlen?= =?UTF-8?q?=20gleicher=20Zeichen=20gefunden?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 03_FLOW/MP/main_mp2_FLOW_a.cpp | 5 +- 03_FLOW/Testat/main_mp2_FLOW_a.cpp | 96 ++++++++++++++++-------------- 07_STD/MP/grundgeruest.cpp | 14 +++-- 3 files changed, 62 insertions(+), 53 deletions(-) diff --git a/03_FLOW/MP/main_mp2_FLOW_a.cpp b/03_FLOW/MP/main_mp2_FLOW_a.cpp index 032dd89..d51e9b1 100644 --- a/03_FLOW/MP/main_mp2_FLOW_a.cpp +++ b/03_FLOW/MP/main_mp2_FLOW_a.cpp @@ -1,6 +1,8 @@ #include /* file main_mp2_FLOW_a.cpp */ #include "../../helpers/AnsiConsole.h" +//TODO: verstehen + AnsiConsole console; int firstLine; int currentTick; Colors currentColor; #define INITPRINT(label) {firstLine=__LINE__;console.printText(2*currentTick,0,label,Colors::BLACK);} #define PRINT printLineNumber(__LINE__) @@ -44,9 +46,6 @@ void test() { - - - void start_Sequence(void){ INITPRINT("Sequence"); PRINT; diff --git a/03_FLOW/Testat/main_mp2_FLOW_a.cpp b/03_FLOW/Testat/main_mp2_FLOW_a.cpp index 238f0cf..cb84102 100644 --- a/03_FLOW/Testat/main_mp2_FLOW_a.cpp +++ b/03_FLOW/Testat/main_mp2_FLOW_a.cpp @@ -1,41 +1,49 @@ #include /* file main_mp2_FLOW_a.cpp */ #include "../../helpers/AnsiConsole.h" -AnsiConsole console; int firstLine; int currentTick; Colors currentColor; +AnsiConsole console; +int firstLine; +int currentTick; +Colors currentColor; #define INITPRINT(label) {firstLine=__LINE__;console.printText(2*currentTick,0,label,Colors::BLACK);} #define PRINT printLineNumber(__LINE__) + void printLineNumber(int lineNumber); void help(int i); + void help2(); + void recurse2(int i, int rounds); - - - - void recurse2(int i, int rounds) { - if(i == 0 && rounds == 2) { + if (i == 0 && rounds == 2) { help2(); - } - else if(i == 0 && rounds == 1) { + } else if (i == 0 && rounds == 1) { recurse2(3, 0); - }else {recurse2((i-1), 2);} + } else { recurse2((i - 1), 2); } } -void help2() {PRINT; + +void help2() { + PRINT; recurse2(3, 1); PRINT; } - void recurse(int i) { - if(i == 0) {help(2); return;} - PRINT;recurse(i-1); + if (i == 0) { + help(2); + return; + } + PRINT; + recurse(i - 1); } -void help(int i) {if(i % 2 == 0)PRINT; + +void help(int i) { + if (i % 2 == 0)PRINT; else { PRINT; recurse(3); @@ -43,13 +51,12 @@ void help(int i) {if(i % 2 == 0)PRINT; } - void iterationA(int x) { - for(int i = 0; i < 3; ++i) + for (int i = 0; i < 3; ++i) PRINT; - if(x % 2 != 0) + if (x % 2 != 0) PRINT; - else + else PRINT; } @@ -61,39 +68,38 @@ void startA() { } -int main(int argc, const char * argv[]) { +int main(int argc, const char *argv[]) { - console.clearScreen(); - - currentColor = Colors::GREEN; + console.clearScreen(); - /* - * 1x Rekursion - * 1x Selektion - * 1x Subroutine - * - * 3x Aufrufe aus: - * 1x Rekursion - * 1x Hilfsfunktion - * 1x main - */ + currentColor = Colors::GREEN; - startA(); - //recurse2(3, 2); - - std::string s; - std::cin >> s; - - - return 0; + /* + * 1x Rekursion + * 1x Selektion + * 1x Subroutine + * + * 3x Aufrufe aus: + * 1x Rekursion + * 1x Hilfsfunktion + * 1x main + */ + + startA(); + //recurse2(3, 2); + + std::string s; + std::cin >> s; + + + return 0; } - -void printLineNumber(int lineNumber){ - std::string line = std::to_string(lineNumber); - currentTick++; - console.printText(currentTick*2-1, 1+lineNumber-firstLine, line, currentColor); +void printLineNumber(int lineNumber) { + std::string line = std::to_string(lineNumber); + currentTick++; + console.printText(currentTick * 2 - 1, 1 + lineNumber - firstLine, line, currentColor); } diff --git a/07_STD/MP/grundgeruest.cpp b/07_STD/MP/grundgeruest.cpp index 2b853fc..7171022 100644 --- a/07_STD/MP/grundgeruest.cpp +++ b/07_STD/MP/grundgeruest.cpp @@ -31,6 +31,8 @@ int main() { unittest_stringSimilarity(); } + +//TODO: Punkte gleichmässig verteilen int stringSimilarity(std::string string1, std::string string2) { //wenn gleicher String, gleich 100 Punkte geben, spart den Rest if(string1 == string2) return 100; @@ -56,25 +58,27 @@ int stringSimilarity(std::string string1, std::string string2) { //gleiche Anzahl an verschiedenen Zeichen +10 Punkte if(string1map.size() == string2map.size()) points += 10; - - //auf gleiche Zeichenanzahl testen - //gleiche Anzahl an gleichen Zeichen int equalCharCount = 0; int equalChars = 0; for(std::pair count : characterCount) { - if(string1map[count.first] == string2map[count.second]) equalCharCount++; - if(string1map[count.first] != 0 && string2map[count.first] != 0) equalChars++; + //BUG: equalCharCount ist nicht immer korrekt + if(string1map[count.first] == string2map[count.first]) equalCharCount++;//gleiche Anzahl an gleichen Zeichen + if(string1map[count.first] != 0 && string2map[count.first] != 0) equalChars++;//Zeichen exsistiert in beiden } if(equalChars > 0) { points += characterCount.size() / equalChars * 10; } if(equalCharCount > 0) { points += characterCount.size() / equalCharCount; + std::cout << "equalCharCount = " << equalCharCount << std::endl; } + + //TODO: Punkte für gleiche Buchstaben und gleiche Buchstaben Anzahl vergeben + return points; }