함수 min()

MIN
LEAST

1 C[ | ]

#include<stdio.h>

int intArray_min(int arr[], int len) {
    int min = arr[0];
    for(int i=1; i<len; i++) {
        if( arr[i]<min ) min = arr[i];
    }
    return min;
}

void main() {
   int nums[] = {3, 6, 2, 8, 1};
   int len = sizeof(nums)/sizeof(nums[0]);
   printf("%d", intArray_min(nums,len));
   // 1
}

2 C#[ | ]

using System;
using System.Linq;
class Program {
    static void Main() {
        double[] nums = {3.14, 77.7, 5, -10.5, -4.4};
        Console.WriteLine( nums.Min() );
        // -10.5
    }
}

3 Excel[ | ]

=MIN(3.14, 77.7, 5, -10.5, -4.4)
// returns -10.5

4 Java[ | ]

import java.util.Arrays;
import java.util.Collections;
public class Main {
    public static void main(String args[]) {
        Double[] nums = {3.14, 77.7, 5.0, -10.5, -4.4};
        Double min = Collections.min(Arrays.asList(nums));
        System.out.println( min );
        // -10.5
    }
}
public class Main {
    public static void main(String args[]) {
        double[] nums = {3.14, 77.7, 5.0, -10.5, -4.4};
        double min = nums[0];
        for(double i:nums)if(min>i)min=i;
        System.out.println( min );
        // -10.5
    }
}

5 JavaScript[ | ]

console.log( Math.min(3.14, 77.7, 5, -10.5, -4.4) );
// -10.5

6 Perl[ | ]

use List::Util qw( min );
print min(3.14, 77.7, 5, -10.5, -4.4) . "\n";
# returns -10.5

7 PHP[ | ]

echo min(3.14, 77.7, 5, -10.5, -4.4);
// returns -10.5

8 Python[ | ]

print( min(3.14, 77.7, 5, -10.5, -4.4) )
# -10.5

9 SQL[ | ]

9.1 Oracle[ | ]

SELECT LEAST(3.14, 77.7, 5, -10.5, -4.4) FROM DUAL;
-- returns -10.5

10 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}