Description:
Given an array of integers your solution should find the smallest integer.
For example:
Given [34, 15, 88, 2] your solution will return 2
Given [34, -345, -1, 100] your solution will return -345
You can assume, for the purpose of this kata, that the supplied array will not be empty.
#include <stddef.h>
int find_smallest_int(int *vec, size_t len)
{
size_t min_idx = 0;
size_t i = 1;
while (i < len)
{
if (vec[min_idx] > vec[i])
min_idx = i;
i++;
}
return vec[min_idx];
}
another solution
사망연산자 쓰기