-3
public class NIS {
public static void insertSort(int[] A)
{
for(int i = 1; i < A.length; i++)
{
int value = A[i];
int j = i - 1;
while(j >= 0 && A[j] > value)
{
A[j + 1] = A[j];
j = j - 1;
}
A[j + 1] = value;
}
}
public static void main(String[] args) {
int a[]={20,10,2,100,1};
insertSort(a);
for (int i=0 ; i <a.length ; i++)
{
System.out.println(" "+a[i]);
}
// in this code there are many problems if anyone of you can help me so plz debugg this code.
}
}
你可以像這樣運行它:1)'javac -cp。 NIS.java' 2)'java NIS' –
請在查詢這個URL之前詢問任何問題:http://stackoverflow.com/help/how-to-ask –
歡迎來到Stack Overflow! 「尋求調試幫助的問題(」爲什麼這個代碼不工作?「)必須包含所需的行爲,特定的問題或錯誤以及在問題本身中重現問題所需的最短代碼。沒有明確問題陳述的問題對其他讀者無益。「引自[我可以在這裏詢問什麼主題?](http://stackoverflow.com/help/on-topic)。 –