Lnode.java
package PloyItem;
/**
*@Author wzy
*@Date 2017年11月12日
*@Version JDK 1.8
*@Description
*/
public class Lnode implements Comparable<Lnode>,Cloneable{
public double coef;
public int exp;
public Lnode next;
public Lnode (double coef,int exp){
this.exp=exp;
this.coef=coef;
next=null;
}
public Lnode(double coef,int exp,Lnode next){
this.exp=exp;
this.coef=coef;
this.next=next;
}
public boolean equals(Object e){
Lnode node=(Lnode)e;
return (exp==node.exp);
}
@Override
protected Object clone() throws CloneNotSupportedException {
// TODO Auto-generated method stub
return super.clone();
}
@Override
public int compareTo(Lnode o) {
// TODO Auto-generated method stub
return 0;
}
}
PloyItemList.java
package PloyItem;
import java.text.DecimalFormat;
import java.util.Scanner;
/**
*@Author wzy
*@Date 2017年11月12日
*@Version JDK 1.8
*@Description
*/
public class PloyItemList implements Cloneable{
private int length;
DecimalFormat df = new DecimalFormat("######0.0");
Lnode first;
@Override
protected PloyItemList clone() throws CloneNotSupportedException {
// TODO Auto-generated method stub
PloyItemList p=(PloyItemList) super.clone();
if(this.first!=null) p.first=(Lnode) this.first.clone();
return p;
}
public PloyItemList(int length)
{
first=null;
this.length=length;
}
public PloyItemList(){
first=null;
length=0;
}
public int size()//获取链表的长度
{
Lnode p=first;
int count=0;
while(p!=null&&p.coef!=