"카타 8급 Find the smallest integer in the array"의 두 판 사이의 차이

잔글 (봇: 카타 8급 PHP 분류 추가)
잔글 (봇: 자동으로 텍스트 교체 (-분류:PHP +))
53번째 줄: 53번째 줄:


[[분류:C++]]
[[분류:C++]]
[[분류:PHP]]
 
[[분류:카타 8급 PHP]]
[[분류:카타 8급 PHP]]

2019년 2월 3일 (일) 04:03 판

1 개요

카타 8급 C
# 🔗 문제 풀이

틀:카타 8급-11

2 C++

#include <vector>
#include <algorithm>
using namespace std; 
int findSmallest(const vector <int>& list) {
  return *min_element(list.begin(), list.end());
}
#include <vector>
#include <algorithm>
using namespace std; 
int findSmallest(const vector <int>& list) {
  return *min_element(list.cbegin(), list.cend());
}
#include <vector>
using namespace std; 
int findSmallest(vector <int> list) {
  int min = list[0];
  for(int x: list) {
    if( x<min ) min=x;
  }
  return min;
}

3 PHP

function smallestInteger ($arr) {
    return min($arr);
}
function smallestInteger ($arr) {
    $min = $arr[0];
    foreach($arr as $num) {
      if($num < $min) $min = $num;
    }
    return $min;
}

4 같이 보기

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