?? mathlinkedlist.java
字號:
package work_1;
public class MathLinkedList {
LinkedList linkedList = null;
public MathLinkedList(LinkedList linkedList) {
this.linkedList = linkedList;
linkedList.resetHead();
// System.out.println(linkedList.getCurrentNode().getData());
}
// 得到和
public double getSum() {
linkedList.resetHead();
double sum = 0;
do {
sum += linkedList.getCurrentNode().getData();
} while (linkedList.hasNextNode());
return sum;
}
// 得到平均數
public double getAverage() {
linkedList.resetHead();
return getSum() / linkedList.getLength();
}
// 得到方差
public double getVariance() {
double temp = 0;
double aver = getAverage();
linkedList.resetHead();
do {
temp += Math.pow((linkedList.getCurrentNode().getData() - aver), 2);
} while (linkedList.hasNextNode());
return temp / this.linkedList.getLength();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -