javaʵÏֵĻôÄɹæÔòµÄ¶àÏîʽ¼ÆËã
»ôÄɹæÔò¶àÏîʽ¼ÆËãÈç¹ûʹÓÃÆÓËصĶàÏîʽÇóÖµ£¬Ê±¼ä¸´ÔÓ¶ÈΪO(n*n)£¬¶øÊÇÓÃÁË»ôÄɹæÔò¿ÉÒÔʹÓõݹé»òÕßµü´úÀ´ÊµÏÖ£¬Ê±¼ä¸´ÔÓ¶ÈÊÇO(n),ÏÂÃæÊÇÔ´´úÂë:
/*
* ʵÏÖ»ôÄɹæÔòµÄ¶àÏîʽ¼ÆËãʱ¼ä¸´ÔÓ¶ÈΪO(N)
*/
public class HuonaRule {
public static void main(String args[])
{
double data[]=new double[]{1.0,2,2,3,4};
double x=3;
System.out.println(huonaFunction(data,x,data.length));
}
/*
* dataΪ¶àÏîʽµÄϵÊýÊý×飬xΪֵ£¬nΪϵÊýÊý×éµÄ³¤¶È
* Y=a0+a1*X+a2*X^2+.....+an*X^n;
* Y=a0+X(a1+X(a2+X(a3+X(...))))
*/
public static double huonaFunction(double[] data,double x,int n)
{
double y=0;
int i=n-1;
while( i>=0 )
{
y=x*y+data[i];
i--;
}
return y;
}
}
Ïà¹ØÎĵµ£º
¿ÉÄÜ´ó¶àÊýJsp¿ª·¢Ô±ÔÚдÍê³ÌÐò²âÊÔͨ¹ýºó£¬²»Ì«»á¹Ø×¢JspÉú³ÉµÄJavaÎļþ£¬Æäʵ£¬Í¨¹ýJava´úÂ룬¸üÄÜÌåÏÖ³ÌÐò´úÂëµÄÕæÕýº¬Ò壬¶Ô½øÒ»²½Ñо¿³ÌÐò´úÂëµÄºǫ́ÔËÐÐÇé¿öÊǷdz£ÓаïÖúµÄ¡£ÀýÈ磬ÓÃJsp±àд´úÂëʱ£¬ÓÐʱºòÓÃ<%! %>£¬ÓÐʱºòÓÃ<% %>£¬¼Ó²»¼Ó¸Ð̾º ......
ÏÂÃæÊÇÓÃjavaʵÏÖµÄÑ¡ÔñÅÅÐò£¬Ã¿´Î´ÓÊý×éÖÐÑ¡È¡×îСµÄÖµ£º
import java.util.Date;
import java.util.Random;
/*
* Ñ¡ÔñÅÅÐò
*/
public class SelectSort {
public static void main(String args[])
{
int len = 40;
Date date = new Date();
Random random = new Random(date.getSeconds());
int ......
Ò»ÏÂÊÇjavaʵÏÖµÄÓÐÒ»¸ö¹é²¢ÅÅÐò£¬×Ô¼º·¢ÏÖ×Ô¼ºµÄ»ù´¡¹¦Ì«²îÁË£¬ËùÒÔ×î½ü¿ªÊ¼Ñ§Ï°Ëã·¨£¬ºÃºÃµÄÁªÏµÃ¿Ò»Ëã·¨£¬¸÷λ´óÉñ²»Òª¼ûЦ£¬Ð´µÄÓдíµÄµØ·½Ï£ÍûÄܹ»Ö¸³öÀ´Ð»Ð»¹þ£º
package sort;
import java.util.Date;
import java.util.Random;
/*
* ¹é²¢ÅÅÐò
*/
public class MergeSort {
public static void main(Stri ......