Skip to content

Instantly share code, notes, and snippets.

@alexnask
Last active December 10, 2015 19:48
Show Gist options
  • Save alexnask/4484322 to your computer and use it in GitHub Desktop.
Save alexnask/4484322 to your computer and use it in GitHub Desktop.
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int foo(int a[], int iter) {
int current = a[iter];
if(iter == 9) return current;
int restMin = foo(a, iter + 1);
if(current < restMin) {
return current;
}
return restMin;
}
main(void)
{
int i , c , a[10] , r = 0 , d;
for (i = 0; i < 10; i ++)
{
printf("Give a number for array a.\n");
scanf("%d",&a[i]);
}
d = a[0];
c = foo(a , 0);
printf("%d\n" , c);
system("pause");
}
min :: Ord a => [a] -> a
min (x:[]) = x
min (x:xs) = if x < xs then x else min xs
import structs/ArrayList
min: func(arr: ArrayList<Int>) -> Int {
val := arr[0]
if(arr getSize() == 1) return val
arr removeAt(0)
restMin := min(arr)
if(val < restMin) {
return val
}
restMin
}
def min(list):
curr = list[0]
if len(list) == 1:
return curr
restMin = min(list[1::])
if curr < restMin:
return curr
return restMin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment