Implement Counting perfect Matches
This commit is contained in:
parent
1d32b4798d
commit
f5ce0edf4c
@ -59,6 +59,25 @@ std::vector<std::string> getCodeGuessFromConsole() {
|
||||
return guess;
|
||||
}
|
||||
|
||||
int countPefectMatches(std::vector<std::string> &v1, std::vector<std::string> &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<std::string> guess = getCodeGuessFromConsole();
|
||||
std::cout << "correct were: " << countPefectMatches(guess, SecretCode) << std::endl;
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user