我需要以下輸出 實施例的連續編號之間的差值:查找在陣列
List Difference
1 0
2 1
3 1
4 1
5 1
:
int array [] = {1, 2, 3, 4, 5};
如果使用用於循環
輸出應在形式進行這裏是我使用的代碼,它工作得很好,直到4,但後來在5它說outofbounds,因爲它看着數組w中的位置5這個不存在。所以,我需要幫助!
代碼:
for (int counter = 0; counter < degreedays.length;++counter){
System.out.println("\t" + degreedays[counter] + "\t\t\t" + (degreedays[counter+1] - degreedays[counter]));
聽起來像家庭作業..... – CtrlDot 2011-04-19 02:49:48
如果這是功課,請標記爲這樣。此外,這個社區在這裏幫助你,而不是爲你做事。所以請告訴我們你到目前爲止做了什麼,以及你被困住了什麼。 – Hristo 2011-04-19 02:49:50
fibunacci serries?好像是這樣。在第二個修改後的版本,它可能看起來像fibunacci – ianace 2011-04-19 02:50:58