< Algorithms < Find maximum
c source code
int findmax(const int a[], int len) {
int curr_max, i;
if(len == 1)
return a[0];
else if(len == 0)
return 0;
curr_max = a[0];
for(i = 1; i < len; i++)
if(a[i] > curr_max)
curr_max = a[i];
return curr_max;
}
This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.