importjava.util.Scanner;publicclassNewtonchazhi{publicstaticvoidmain(String[]args){inti,j;System.out.println(请输入要求的值:);Scannersa=newScanner(System.in);doublet=sa.nextDouble();System.out.println(请输入端点的个数:);Scannersc=newScanner(System.in);intn=sc.nextInt();System.out.println(请输入各端点横坐标:);Scannersd=newScanner(System.in);doublex[]=newdouble[n];for(i=0;in;i++){x[i]=sd.nextDouble();}System.out.println(请输入各端点纵坐标:);Scannersb=newScanner(System.in);doublea[][]=newdouble[n][n];for(i=0;in;i++){a[i][0]=sb.nextDouble();}for(i=1;in;i++){for(j=i;jn;j++){a[j][i]=(a[j][i-1]-a[j-1][i-1])/(x[j]-x[j-i]);}}doubleq[]=newdouble[n];doublesum=a[0][0];for(i=1;in;i++){q[0]=1;q[i]=q[i-1]*(t-x[i-1]);sum=a[i][i]*q[i]+sum;}System.out.println(由牛顿插值法求得x=+t+处的函数值是:+sum);}}