📄 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 + -