Last active
December 10, 2015 19:48
-
-
Save alexnask/4484322 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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"); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
min :: Ord a => [a] -> a | |
min (x:[]) = x | |
min (x:xs) = if x < xs then x else min xs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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