MIPI_AdvancedC_FRTK/Lect1/05_page_9.c
2024-11-14 08:45:50 +03:00

21 lines
424 B
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
int find_odd_element(int32_t arr[], size_t n)
{
int32_t res = 0;
for (size_t i = 0; i < n; i++)
res ^= arr[i];//А^B^A = A
return res;
}
int main(void) {
int32_t arr[] = {17,17,24,99,24,24,24};
size_t n = sizeof(arr) / sizeof(arr[0]);
printf("The element is %" PRId32,
find_odd_element(arr, n));
return 0;
}