Last active
August 29, 2015 14:13
-
-
Save JustinChoi21/79cc2f5212b0fc9d7e0d to your computer and use it in GitHub Desktop.
Data Structures & Algorithms with Javascript 문제 풀이
This file contains 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
/* | |
* p63 연습문제3 | |
* 이차원 배열을 이용해 월간 온도 자료를 저장하도록 weeklyTemps 객체를 고치시오. | |
* 월간 평균, 지정한 주의 평균, 모든 주의 평균을 출력하는 함수를 만드시오. | |
*/ | |
var temps = [][]; //이차원 배열 데이터 | |
var Temps = function (temps){ | |
this.temps = temps; | |
}; | |
// 월간 평균 | |
Temps.prototype.monthAverage = function () { | |
var monthTotal = 0; | |
var monthLength = 0; | |
var monthAverage = 0; | |
for (var inx = 0; inx < this.temps.length; inx++) { | |
for (var jnx = 0; jnx < this.temps[inx].length; jnx++) { | |
monthTotal += this.temps[inx][jnx]; | |
monthLength++; | |
} | |
} | |
monthAverage = monthTotal / monthLength; | |
return monthAverage.toFixed(2); | |
}; | |
// 지정 주간 평균 | |
Temps.prototype.targetWeekAverage = function (week) { | |
var weekTotal = 0; | |
var weekAverage = 0; | |
for (var inx = 0; inx < this.temps[week].length; inx++) { | |
weekTotal += this.temps[week][inx]; | |
} | |
weekAverage = weekTotal / this.temps[week].length; | |
}; | |
// 모든 주간 평균 => 월간 평균과 동일 | |
Temps.prototype.allWeekAverage = function () { | |
}; |
This file contains 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
// List 클래스 | |
function List() { | |
this.listSize = 0; | |
this.pos = 0; | |
this.dataStore = []; | |
this.clear = clear; | |
this.find = find; | |
this.toString = toString; | |
this.insert = insert; | |
this.append; | |
this.remove; | |
this.front; | |
this.end | |
this.prev | |
this.next | |
this.length | |
this.currPos | |
this.moveTo | |
this.getElement | |
this.length | |
this.contains | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment