【java 面試100】20.輸入一個表示整數的字符串,把該字符串轉換成整數並輸出

(思路參照july博客,用java從新實現)java 輸入一個表示整數的字符串,把該字符串轉換成整數並輸出。例如輸入字符串"345",則輸出整數345 spa public class Atoi { public int atoi(String str){ int neg=0; int i=0; if(str.charAt(i)=='-'){ i++; neg=1;
相關文章
相關標籤/搜索