我为您实现了alternateSum方法:
public double alternatingSum() { double alternatingSum = 0; if(data != null || dataSize > 0) { for(int i = 0; i < dataSize; i = i + 2) { alternatingSum += data[i]; } for(int i = 1; i < dataSize; i = i + 2) { alternatingSum -= data[i]; } } return alternatingSum;}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)