MIPI_AdvancedC_FRTK/Lect1/05_page_9.c

21 lines
424 B
C
Raw Normal View History

2024-11-14 08:45:50 +03:00
#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;
}