diff options
feat(Week07): Add solutions
1 files changed, 26 insertions, 0 deletions
| -rw-r--r-- | Week07/Exercise10.cpp | 26 |
diff --git a/Week07/Exercise10.cpp b/Week07/Exercise10.cpp new file mode 100644 index 0000000..f31d4b7 --- /dev/null +++ b/Week07/Exercise10.cpp @@ -0,0 +1,26 @@ +#include <iostream> + +unsigned int countSameElementsOnSameIndecies(int* arr1, unsigned int size1, int* arr2, unsigned int size2) { + unsigned int count = 0; + unsigned int size = size1 < size2 ? size1 : size2; + + for (unsigned int i = 0; i < size; i++) + if (arr1[i] == arr2[i]) + count++; + + return count; +} + +int main() { + const unsigned int SIZE1 = 10, SIZE2 = 15; + int series1[SIZE1], series2[SIZE2]; + + for (unsigned int i = 0; i < SIZE1; i++) + std::cin >> series1[i]; + for (unsigned int i = 0; i < SIZE2; i++) + std::cin >> series2[i]; + + std::cout << countSameElementsOnSameIndecies(series1, SIZE1, series2, SIZE2) << std::endl; + + return 0; +} |
