diff --git a/Aufg5/Mastermind.cpp b/Aufg5/Mastermind.cpp index d51f7a6..2124f70 100644 --- a/Aufg5/Mastermind.cpp +++ b/Aufg5/Mastermind.cpp @@ -59,6 +59,25 @@ std::vector getCodeGuessFromConsole() { return guess; } +int countPefectMatches(std::vector &v1, std::vector &v2) { + int shorterSize; + + if (v1.size() < v2.size()) { + shorterSize = v1.size(); + } else { + shorterSize = v2.size(); + } + + int count = 0; + for (int i = 0; i < shorterSize; i++) { + if (v1[i] == v2[i]) { + count++; + } + } + + return count; +} + @@ -73,5 +92,6 @@ void Aufg5Main() { printAllStringsInVector(SecretCode); std::vector guess = getCodeGuessFromConsole(); + std::cout << "correct were: " << countPefectMatches(guess, SecretCode) << std::endl; }