ÉèΪÊ×Ò³ ¼ÓÈëÊÕ²Ø

TOP

×îÐÂJAVA±à³ÌÌâÈ«¼¯_50Ìâ¼°´ð°¸(Ò»)
2014-11-24 02:23:10 ¡¾´ó ÖРС¡¿ ä¯ÀÀ:4397´Î
Tags£º×îРJAVA ±à³Ì È«¼¯ _50 ´ð°¸

дһ¸öº¯Êý£¬ÀýÈ磺¸øÄãµÄ a b c ÔòÊä³ö abc acb bac bca cab cba


import java.util.ArrayList;


import java.util.List;


public class NumTest {


public static void main(String[] args) {


String s=¡±ABCD¡±;//Ô­×Ö·û´®


List result = list(s, ¡±");//Áгö×Ö·ûµÄ×éºÏ£¬·ÅÈëresult


System.out.println(result.size());;


System.out.println(result);


}


/**


* Áгö»ù´¡×Ö·û´®(base)µÄËùÓÐ×éºÏ


* @param base ÒÔ¸Ã×Ö·û´®×÷Ϊ»ù´¡×Ö·û´®£¬½øÐÐÑ¡ÔñÐÔ×éºÏ¡£


* @param buff ËùÇó×Ö·û´®µÄÁÙʱ½á¹û


* @param result ´æ·ÅËùÇó½á¹û


*/


public static List list(String base,String buff){


List result = new ArrayList();//´æ·Å½á¹ûÐÅÏ¢¡£


if(base.length()<=0){


result.add(buff);


}


for(int i=0;i

List temp = list(new StringBuilder(base).deleteCharAt(i).toString(),buff+base.charAt(i));


result.addAll(temp);


}


return result;


}


}


+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


public static void main(String[] args) {


String s=¡±ABCD¡±;//Ô­×Ö·û´®


List result = new ArrayList();//´æ·Å½á¹ûÐÅÏ¢¡£


list(s, ¡±", result);//Áгö×Ö·ûµÄ×éºÏ£¬·ÅÈëresult


System.out.println(result.size());;


System.out.println(result);


}


/**


* Áгö»ù´¡×Ö·û´®(base)µÄËùÓÐ×éºÏ


* @param base ÒÔ¸Ã×Ö·û´®×÷Ϊ»ù´¡×Ö·û´®£¬½øÐÐÑ¡ÔñÐÔ×éºÏ¡£


* @param buff ËùÇó×Ö·û´®µÄÁÙʱ½á¹û


* @param result ´æ·ÅËùÇó½á¹û


*/


public static void list(String base,String buff,List result){


if(base.length()<=0){


result.add(buff);


}


for(int i=0;i

list(new StringBuilder(base).deleteCharAt(i).toString(),buff+base.charAt(i),result);


}


}


+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


дһ¸öº¯Êý£¬¸øÄãÒ»¸ö×Ö·û´® µ¹ÐòÊä³öÀ´


public String getString(String str){


if(str!=null){


String newStr = ¡°¡±;


for(int i=0;i

{


char c = str.charAt(str.length()-1-i);


newStr = newStr + c;


}


return newStr;


}else{


return null;


}


}


²»Ê¹ÓÃÖмä±äÁ¿ °ÑÁ½¸ö±äÁ¿µÄÖµ»¥»»


int a=10;


int b=100;


a=a*b;


b=a/b;


a=a/b;


System.out.print(¡°a=¡±+a+¡± b=¡±+b);


ÕÛ°ë²éÕÒ


public class Test


{


public static int[] data = { 12, 15, 20, 10, 19, 3, 89, 32, 39, 47, 55 }; // ԭʼÊý¾Ý


public static int counter = 1; // ¼ÆÊýÆ÷


public static int len = data.length;


public static void main(String args[])


{


//Òª²éÕÒµÄÊý


int keyValue = 89;


Test t = new Test();


boolean b = t.BinarySearch(keyValue);


if(b)


{


// Êä³ö²éÕÒ´ÎÊý


System.out.println(¡°Search Time = ¡± + counter);


}else


{


// Êä³öûÓÐÕÒµ½Êý¾Ý


System.out.println(¡°No Found!!¡±);


}


}


// ¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª


// ÕÛ°ë²éÕÒ·¨


public static boolean BinarySearch(int keyValue)


{


int left; // ×ó±ß½ç±äÁ¿


int right; // Óұ߽ç±äÁ¿


int middle; // ÖÐλÊý±äÁ¿


System.out.println(¡°Êý¾Ý³¤¶È£º¡±+len);


left = 0;


right = len ¨C 1;


while (left <= right)


{


//ÓÉÓÚÔ´Êý¾Ý²»ÊÇ˳ÐòµÄ£¬ÐèÏȽøÐÐÅÅÐò


int temp;


for(int i=0;i

{


for(int j=0;j

{


if(data[j]>data[j+1])


{


temp = data[j];


data[j] = data[j+1];


data[j+1] = temp;


}


}


}


middle = (left + right) / 2;


// Óû²éÕÒÖµ½ÏС


if (keyValue < data[middle])


{


right = middle ¨C 1; // ²éÕÒÇ°°ë¶Î


}


// Óû²éÕÒÖµ½Ï´ó


else if (keyValue > data[middle])


{


left = middle + 1; // ²éÕÒºó°ë¶Î


}


// ²éÕÒµ½Êý¾Ý


else if (keyValue == data[middle])


{


System.out.println(¡°data[" + middle + "] = ¡± + data[middle]);


return true;


}


counter++;


}


return false;


} }


1. ½«this is a test ת»¯ÎªThis Is A Test


String str=¡±this is a man¡±;


char c[]=new char[str.length()];


str.getChars(0,str.length(),c,0);


if(c[0]>=¡¯a'&&c[0]<=¡¯z')


{


c[0]=(char)(c[0]-32);


}


for(int i=1;i<=c.length-1;i++)


{


if(c[i]==¡¯ ¡®)


{


c[i+1]=(char)(c[i+1]-32);


}


}


str=new String(c);


System.out.print(str);


2. ½«This is a testµ¹×ÅÊä³ötset a si sihT £¨ÓÃStringBuffer£©


String str=¡±this is a man¡±;


StringBuffer sb=new StringBuffer(str.length());


for(int j = str.length()-1;j>=0;j¨C)


{


sb.append(str.charAt(j));


}


System.out.print(sb);


3. ÓõݹéÇóN!=N*(N-1)*(N-2)*¡­*2*1;


long digui(int i)


{if(i==0||i==1)


{


return 1;


}


else


{


return i*digui(i-1);


}

Ê×Ò³ ÉÏÒ»Ò³ 1 2 3 4 5 6 7 ÏÂÒ»Ò³ βҳ 1/9/9
¡¾´ó ÖРС¡¿¡¾´òÓ¡¡¿ ¡¾·±Ìå¡¿¡¾Í¶¸å¡¿¡¾Êղء¿ ¡¾ÍƼö¡¿¡¾¾Ù±¨¡¿¡¾ÆÀÂÛ¡¿ ¡¾¹Ø±Õ¡¿ ¡¾·µ»Ø¶¥²¿¡¿
ÉÏһƪ£ºexit£¨£©º¯ÊýºÍreturn Óï¾äÓÐʲô.. ÏÂһƪ£ºOracle DBA±ÊÊÔÌâ

×îÐÂÎÄÕÂ

ÈÈÃÅÎÄÕÂ

Hot ÎÄÕÂ

Python

C ÓïÑÔ

C++»ù´¡

´óÊý¾Ý»ù´¡

linux±à³Ì»ù´¡

C/C++ÃæÊÔÌâÄ¿