Website Summary Files Commits Branches @commit @diff @stats
path: root / Week06 / Exercise04.cpp
diff options
context:
space:
mode:
Commitec8ecd4dc19854007428761c330303854478201f (patch)
Author
 Syndamia <kamen@syndamia.com>
2025-11-06 19:13:54 +0200
Committer
 Syndamia <kamen@syndamia.com>
2025-11-06 19:15:07 +0200
Files662f55a328b60a70273a5e6fc564b1511da906cf /Week06/Exercise04.cpp
upp-2025-solutions-ec8ecd4dc19854007428761c330303854478201f.tar
upp-2025-solutions-ec8ecd4dc19854007428761c330303854478201f.tar.gz
upp-2025-solutions-ec8ecd4dc19854007428761c330303854478201f.zip
Parent9242ebc4c69f2c1f550ddcc0e9235f3f409554c7 (diff)
feat(Week06): Add exercises and solutions
1 files changed, 27 insertions, 0 deletions
-rw-r--r--Week06/Exercise04.cpp27
diff --git a/Week06/Exercise04.cpp b/Week06/Exercise04.cpp
new file mode 100644
index 0000000..c7a490e
--- /dev/null
+++ b/Week06/Exercise04.cpp
@@ -0,0 +1,27 @@
+#include <iostream>
+
+int main() {
+ const unsigned int SIZE_FIRST = 15, SIZE_SECOND = 5;
+ int first[SIZE_FIRST], second[SIZE_SECOND];
+
+ for (unsigned int i = 0; i < SIZE_FIRST; i++)
+ std::cin >> first[i];
+ for (unsigned int i = 0; i < SIZE_SECOND; i++)
+ std::cin >> second[i];
+
+ unsigned int counts[SIZE_SECOND] = { 0 };
+ for (unsigned int i = 0; i < SIZE_FIRST; i++) {
+ for (unsigned int j = 0; j < SIZE_SECOND; j++) {
+ if (first[i] == second[j]) {
+ counts[j]++;
+ break;
+ }
+ }
+ }
+
+ for (unsigned int i = 0; i < SIZE_SECOND; i++)
+ std::cout << counts[i] << ' ';
+ std::cout << std::endl;
+
+ return 0;
+}