Website Summary Files Commits Branches @commit @diff @stats
path: root / Sem. 07 / Solutions / Task2
diff options
context:
space:
mode:
1 files changed, 19 insertions, 0 deletions
-rw-r--r--Sem. 07/Solutions/Task219
diff --git a/Sem. 07/Solutions/Task2 b/Sem. 07/Solutions/Task2
new file mode 100644
index 0000000..8d5cf98
--- /dev/null
+++ b/Sem. 07/Solutions/Task2
@@ -0,0 +1,19 @@
+#include <iostream>
+
+using namespace std;
+
+int findSingle(int* arr, unsigned size)
+{
+ int temp = arr[0];
+ for (int i = 1; i < size; i++)
+ temp = temp ^ arr[i];
+
+ return temp;
+}
+
+int main()
+{
+ int array[] = { 9,18,9,12,18,15,12 };
+ unsigned size = sizeof(array) / sizeof(array[0]);
+ cout << findSingle(array, size);
+}