我的評論
re: 過去的一年[未登錄] titan 2014-02-08 14:35
貌似不是在華為就是在阿里工作
re: Java經典算法集[未登錄] titan 2013-11-21 01:28
public class SoftTest {
public static void main(String[] args)
{
for(int i=122345; i<=543221 ;i++ )
{
String s = String.valueOf(i);
if(s.indexOf("2")>=0&&s.indexOf("3")>=0&&s.indexOf("4")>=0&&s.indexOf("5")>=0&& s.indexOf("4")!=2&&s.indexOf("1")>=0&&s.indexOf("35")==-1&&s.indexOf("53")==-1&&s.indexOf("2",s.indexOf("2")+1)>=0)
{
System.out.println(i);
}
}
}
}
public static void main(String[] args)
{
for(int i=122345; i<=543221 ;i++ )
{
String s = String.valueOf(i);
if(s.indexOf("2")>=0&&s.indexOf("3")>=0&&s.indexOf("4")>=0&&s.indexOf("5")>=0&& s.indexOf("4")!=2&&s.indexOf("1")>=0&&s.indexOf("35")==-1&&s.indexOf("53")==-1&&s.indexOf("2",s.indexOf("2")+1)>=0)
{
System.out.println(i);
}
}
}
}
re: 金額數字轉中文大寫[未登錄] titan 2013-11-20 23:59
/*
* 需求:自動轉換人民幣大寫金額的程序
*
* 思路:
* 獲取一個double my
* 格式化double,格式:##0.00,轉換成去掉小數點的字符串formatDouble
* 定義大寫數字數組的String[] money和單位數組String[] unit
* 判斷字符串formatDouble的長度,通過角標獲取每個字符,遍歷字符串,用角標獲取單位,用值獲取大寫數字,將獲取每次循環獲得的結果存入一個字符串緩沖區
* 此時有兩種情況出現:
* 1、循環本次值也為0,就沒有必要存入;
* 2、上次值為0,本次值不為0,就需要在本次前面加一個字符串“零”。
* 解決辦法:定義變量moneybj,用于存入本次值,加以判斷確定存入什么值。
* 當值為0時,無法解決金額達到萬或億或萬億時,單位不能存入緩沖區,
* 解決辦法:定義一個變量unitbj,用于判斷
* 1、當0值“萬”存入后,鎖死標記,直到有非0值存入時才打開
* 2、億在整個存入過程中只可能出現一次,所以不用判斷,只要有“億”,直接存入并鎖死標記。
* 3、
*
* 注意:
* 本方法最大到千億;
* 調用方法前,注意判斷金額值為0和負數。為零直接打印輸出零,為負數乘以-1后調用方法,在結果前面加”負“。
*/
package test;
import java.text.DecimalFormat;
class Test
{
public static void main(String[] args)
{
double my = 10001000.9;
if (formatdouble(my).equals("000") || (formatdouble(my).equals("-000")) )
sop("人民幣零元整");
else
{
if (my<-0.0)
sop("人民幣負"+strStandard(strUppercase(my*-1.0)));
else
sop("人民幣"+strStandard(strUppercase(my)));
}
}
//按人民幣大寫的格式格式化
private static String strStandard(String s)
{
if (s.indexOf("分")==-1)
s= s+"整" ;
return s;
}
//定義大寫數組和單位數組,并遍歷格式化后的字符串,退回一個字符串
private static String strUppercase(double my)
{
//定義大寫unit
String[] unit = {"仟","佰","拾","萬","仟","佰","拾","億","仟","佰","拾","萬","仟","佰","拾","元","角","分"};
//定義大寫單位money
String[] money = {"零","壹","貳","叁","肆","伍","陸","柒","捌","玖"};
//定義緩沖區
StringBuilder strBuilder = new StringBuilder();
//格式化
String strFormat = formatdouble(my);
//遍歷
int strlength=strFormat.length();
int moneybj = 1;//用于標記上次money值是否為零
int unitbj=1;//用于標記在money值等于0的情況下“萬”是否存入過
for(int i=0;i<strlength ; i++)
{
int value = Integer.parseInt(String.valueOf(strFormat.charAt(i)));
if (moneybj!=0 & value!=0 )//情況一:上次和本次值不為0,直接存入
{
strBuilder.append(money[value]).append(unit[unit.length-strlength+i]);
moneybj=value;
unitbj=1;
}
if(moneybj==0 & value!=0)//情況二:上次值為0,本次值不為0,加“零“存入
{
strBuilder.append("零").append(money[value]).append(unit[unit.length-strlength+i]);
moneybj=value;
unitbj=1;
}
if(moneybj==0 & value==0)//情況三:上次和本次值為0,不存入
{
if (unitbj==1 && unit[unit.length-strlength+i].equals("萬") )
{
strBuilder.append("萬");
unitbj=0;
}
if (unit[unit.length-strlength+i].equals("元") )//解決如果元位上是0的問題
{
strBuilder.append("元");
}
if (unit[unit.length-strlength+i].equals("億") )
{
strBuilder.append("億");
unitbj=0;
}
moneybj=value;
}
if(moneybj!=0 & value==0)//情況三:上次值不為0,本次值為0,不存入
{
if (unitbj==1 && unit[unit.length-strlength+i].equals("萬") )
{
strBuilder.append("萬");
unitbj=0;
}
if (unit[unit.length-strlength+i].equals("元") )//解決如果元位上是0的問題
{
strBuilder.append("元");
}
if (unit[unit.length-strlength+i].equals("億") )
{
strBuilder.append("億");
unitbj=0;
}
moneybj=value;
}
}
//在這種情況下前面會有“零”或 ”元“的存入,如 0.1 ,此時需要去掉“零”
if (strBuilder.indexOf("零")==0)
strBuilder.replace(0, 1, "");
if (strBuilder.indexOf("元")==0)
strBuilder.replace(0, 1, "");
return strBuilder.toString();
}
//格式化字符串并退回一個字符串;
private static String formatdouble(double my)
{
DecimalFormat format = new DecimalFormat("##0.00");
//刪除小數點
String str = format.format(my);
return str.replace(".","");
}
//打印輸出
private static void sop(Object obj)
{
System.out.println(obj);
}
}
* 需求:自動轉換人民幣大寫金額的程序
*
* 思路:
* 獲取一個double my
* 格式化double,格式:##0.00,轉換成去掉小數點的字符串formatDouble
* 定義大寫數字數組的String[] money和單位數組String[] unit
* 判斷字符串formatDouble的長度,通過角標獲取每個字符,遍歷字符串,用角標獲取單位,用值獲取大寫數字,將獲取每次循環獲得的結果存入一個字符串緩沖區
* 此時有兩種情況出現:
* 1、循環本次值也為0,就沒有必要存入;
* 2、上次值為0,本次值不為0,就需要在本次前面加一個字符串“零”。
* 解決辦法:定義變量moneybj,用于存入本次值,加以判斷確定存入什么值。
* 當值為0時,無法解決金額達到萬或億或萬億時,單位不能存入緩沖區,
* 解決辦法:定義一個變量unitbj,用于判斷
* 1、當0值“萬”存入后,鎖死標記,直到有非0值存入時才打開
* 2、億在整個存入過程中只可能出現一次,所以不用判斷,只要有“億”,直接存入并鎖死標記。
* 3、
*
* 注意:
* 本方法最大到千億;
* 調用方法前,注意判斷金額值為0和負數。為零直接打印輸出零,為負數乘以-1后調用方法,在結果前面加”負“。
*/
package test;
import java.text.DecimalFormat;
class Test
{
public static void main(String[] args)
{
double my = 10001000.9;
if (formatdouble(my).equals("000") || (formatdouble(my).equals("-000")) )
sop("人民幣零元整");
else
{
if (my<-0.0)
sop("人民幣負"+strStandard(strUppercase(my*-1.0)));
else
sop("人民幣"+strStandard(strUppercase(my)));
}
}
//按人民幣大寫的格式格式化
private static String strStandard(String s)
{
if (s.indexOf("分")==-1)
s= s+"整" ;
return s;
}
//定義大寫數組和單位數組,并遍歷格式化后的字符串,退回一個字符串
private static String strUppercase(double my)
{
//定義大寫unit
String[] unit = {"仟","佰","拾","萬","仟","佰","拾","億","仟","佰","拾","萬","仟","佰","拾","元","角","分"};
//定義大寫單位money
String[] money = {"零","壹","貳","叁","肆","伍","陸","柒","捌","玖"};
//定義緩沖區
StringBuilder strBuilder = new StringBuilder();
//格式化
String strFormat = formatdouble(my);
//遍歷
int strlength=strFormat.length();
int moneybj = 1;//用于標記上次money值是否為零
int unitbj=1;//用于標記在money值等于0的情況下“萬”是否存入過
for(int i=0;i<strlength ; i++)
{
int value = Integer.parseInt(String.valueOf(strFormat.charAt(i)));
if (moneybj!=0 & value!=0 )//情況一:上次和本次值不為0,直接存入
{
strBuilder.append(money[value]).append(unit[unit.length-strlength+i]);
moneybj=value;
unitbj=1;
}
if(moneybj==0 & value!=0)//情況二:上次值為0,本次值不為0,加“零“存入
{
strBuilder.append("零").append(money[value]).append(unit[unit.length-strlength+i]);
moneybj=value;
unitbj=1;
}
if(moneybj==0 & value==0)//情況三:上次和本次值為0,不存入
{
if (unitbj==1 && unit[unit.length-strlength+i].equals("萬") )
{
strBuilder.append("萬");
unitbj=0;
}
if (unit[unit.length-strlength+i].equals("元") )//解決如果元位上是0的問題
{
strBuilder.append("元");
}
if (unit[unit.length-strlength+i].equals("億") )
{
strBuilder.append("億");
unitbj=0;
}
moneybj=value;
}
if(moneybj!=0 & value==0)//情況三:上次值不為0,本次值為0,不存入
{
if (unitbj==1 && unit[unit.length-strlength+i].equals("萬") )
{
strBuilder.append("萬");
unitbj=0;
}
if (unit[unit.length-strlength+i].equals("元") )//解決如果元位上是0的問題
{
strBuilder.append("元");
}
if (unit[unit.length-strlength+i].equals("億") )
{
strBuilder.append("億");
unitbj=0;
}
moneybj=value;
}
}
//在這種情況下前面會有“零”或 ”元“的存入,如 0.1 ,此時需要去掉“零”
if (strBuilder.indexOf("零")==0)
strBuilder.replace(0, 1, "");
if (strBuilder.indexOf("元")==0)
strBuilder.replace(0, 1, "");
return strBuilder.toString();
}
//格式化字符串并退回一個字符串;
private static String formatdouble(double my)
{
DecimalFormat format = new DecimalFormat("##0.00");
//刪除小數點
String str = format.format(my);
return str.replace(".","");
}
//打印輸出
private static void sop(Object obj)
{
System.out.println(obj);
}
}
re: 另一個基于jquery的樹插件[未登錄] Titan 2009-11-21 11:24
請發我一下源碼和DEMO,非常感謝!
mentien@163.com
mentien@163.com
re: 提前N久的揭秘:《構建高性能的大型分布式Java應用》書的大概內容[未登錄] Titan 2009-03-06 12:48
期待盡快看到!
re: 羅列一下自己看過了的小說 Titan 2006-02-12 14:46
衰聰,你小子擺明抬杠嗎,^_^