我不知道爲什麼這段代碼會產生以下輸出,當我嘗試乘以2個int值。這可能太笨了,但我不明白。我已經將代碼粘貼在這裏輸出雙int轉換messup
public static void main(String[] args) {
// TODO code application logic here
String numstring = "12122";
char[] numArray = numstring.toCharArray();
int num =0;
int index = 10;
int count = 0;
for(int i=numArray.length-1;i>=0;i--){
int ind = (int)(Math.pow(index,count));
System.out.print(numArray[i]+"*"+ind);
System.out.println(" prints as ----->"+numArray[i]*ind);
count++;
}
}
輸出:
2*1 prints as ----->50
2*10 prints as ----->500
1*100 prints as ----->4900
2*1000 prints as ----->50000
1*10000 prints as ----->490000
urgghhh..I恨自己FR這...感謝 –
非常歡迎你指出了這一點! – jh314