0
현재 다항식을 수정하여 미분을 취하는 메서드를 작성해야합니다. 반환 형식으로 작동하는 함수를 작성할 수 있습니다. 내가 코드의 상부 사용하여 무효으로 바꿀 수있는 방법다항식 유래 물 (void 버전)
public PolynomialSortedList differentiate() {
PolynomialSortedList res = new PolynomialSortedList();
for(PolyNode tmp = poly; tmp != null; tmp = tmp.next)
{
if(tmp.exp != 0)
res.addTerm(tmp.coef * tmp.exp, tmp.exp - 1);
}
return res;
}
: 다음은 코드의 myPolyList.differentiate();
말하여 차별화를 호출한다고 가정
public class PolynomialSortedList implements Polynomial {
private PolyNode poly;
private double TOLERANCE = 0.00000001;
public PolynomialSortedList() {
poly = null;
}
private static class PolyNode {
int coef;
int exp;
PolyNode next;
PolyNode(int coef, int exp,PolyNode next) {
this.coef = coef;
this.exp = exp;
this.next = next;
}
}
}