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
반응형
'개발 > html,Thymeleaf' 카테고리의 다른 글
javascript 테트리스 만들기 (0) | 2016.12.13 |
---|---|
자바스크립트 이벤트 바인딩 (1) | 2016.05.30 |
PHP [phpMyadmin 처럼 만들어 보기] table 검색/insert/update/delete (0) | 2015.10.23 |
php mysql 테이블을 검색/컬럼 및 데이터 출력 (0) | 2015.10.22 |
php maiil 전송/이메일 (0) | 2015.10.19 |
댓글