1
0
Fork 0
mirror of https://gitlab.com/mfocko/CodeWars.git synced 2024-11-09 11:09:07 +01:00
CodeWars/7kyu/most_digits/solution.c

21 lines
418 B
C
Raw Normal View History

#include <stddef.h>
#include <math.h>
int find_longest(int *numbers, size_t numbers_size)
{
double digits = floor(log10(fabs(numbers[0])));
int number = numbers[0];
for (size_t i = 1; i < numbers_size; i++)
{
double digits_now = floor(log10(fabs(numbers[i])));
if (digits_now > digits)
{
digits = digits_now;
number = numbers[i];
}
}
return number;
}