728x90
반응형
javascript 함수-1
<html><head><meta charset="utf-8"><script src="bubble.js"></script><script>var scores=[60,60,40,30,20,10,61,51,41,31,21,11,62,52,42,32,22,12,63,53,43,33,23,13,64,54,44,34,24,14,65,55,45,35,65,15];var costs=[.60,.60,.40,.30,.20,.10,.61,.51,.41,.31,.21,.11,.62,.52,.42,.32,.22,.12,.63,.53,.43,.33,.23,.13,.64,.54,.44,.34,.24,.14,.65,.55,.45,.35,.65,.15];var highScore = printAndget(scores);var bestSolution=best(scores,highScore);var extt=minCost(scores,costs);var exttHighScore = printAndget(extt);console.log(bestSolution);console.log("실험횟수:"+scores.length);console.log("최고점수:"+highScore);console.log("최대 효율성:"+exttHighScore);</script></head><body></body></html>bubble.js
function printAndget(scores){for(var i = 0; i< scores.length; i++){var highScore = 0;if(highScore < scores[i]){highScore = scores[i];}}return highScore;}function best(scores, highScore){var bestSolution=[];for(var j = 0; j<scores.length; j++){if(highScore == scores[j]){bestSolution.push(j);}}return bestSolution;}function minCost(scores,costs){var extt=[];var exttNumber;for(var i=0;i<scores.length;i++){extt.push(scores[i]*costs[i]);}console.log(extt);return extt;}
728x90
반응형
'IT > 개발' 카테고리의 다른 글
자바스크립트 이벤트 바인딩 (1) | 2016.05.30 |
---|---|
Android Studio 설치 에서 나타난 문제점 (1) | 2016.05.18 |
Servlet 개념 정확히 알아가기 (0) | 2016.01.11 |
HTTP 프로토콜 알아보기-2 (0) | 2016.01.06 |
HTTP 프로토콜 알아보기-1 (0) | 2016.01.05 |
댓글