E盘java文件夹下有两个文件Sort.java和 SortTest.java
Sort.java里的代码
[code]
public class Sort 
{
private int[] array;
//构造函数
public Sort(int[] arr)
{
array = arr;
} //插入排序
public void insertSort()
{
int temp;
int i, j;

for(i = 1; i < array.length; i++)
{
temp = array[i];

for(j = i - 1; j >= 0 && array[j] > temp; j--)
{
array[j+1] = array[j];

}
array[j+1] = temp;
}

}
}
public class Sort 
{
private int[] array;
//构造函数
public Sort(int[] arr)
{
array = arr;
} //插入排序
public void insertSort()
{
int temp;
int i, j;

for(i = 1; i < array.length; i++)
{
temp = array[i];

for(j = i - 1; j >= 0 && array[j] > temp; j--)
{
array[j+1] = array[j];

}
array[j+1] = temp;
}

}
}
[/code]
SortTest.java里的代码
[code]
import java.io.*;
public class SortTest { /**
 * @param args
 * @throws IOException 
 * @throws NumberFormatException 
 */
public static void main(String[] args) throws NumberFormatException, IOException {
// TODO Auto-generated method stub
System.out.println("Please entey the number of int you want to sort");
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
int size = Integer.parseInt(in.readLine().trim());
int[] array = new int[size];
for(int i =0; i < size; i++)
{
array[i] = (int)(Math.random()*100);
}

Sort sort = new Sort(array);
sort.insertSort();
System.out.println("The array after sorted");
for(int i =0; i < size; i++)
{
System.out.print(array[i] + " ");
} }}[/code]
编译的最终结果是找不到文件.
以上代码在eclipse里编译调试可通过希望各位大哥帮帮忙

解决方案 »

  1.   

    E盘java文件夹下有两个文件Sort.java和 SortTest.java
    Sort.java里的代码
    public class Sort 
    {
    private int[] array;
    //构造函数
    public Sort(int[] arr)
    {
    array = arr;
    } //插入排序
    public void insertSort()
    {
    int temp;
    int i, j;

    for(i = 1; i < array.length; i++)
    {
    temp = array[i];

    for(j = i - 1; j >= 0 && array[j] > temp; j--)
    {
    array[j+1] = array[j];

    }
    array[j+1] = temp;
    }

    }
    }
    SortTest.java里的代码
    import java.io.*;
    public class SortTest { /**
     * @param args
     * @throws IOException 
     * @throws NumberFormatException 
     */
    public static void main(String[] args) throws NumberFormatException, IOException {
    // TODO Auto-generated method stub
    System.out.println("Please entey the number of int you want to sort");
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int size = Integer.parseInt(in.readLine().trim());
    int[] array = new int[size];
    for(int i =0; i < size; i++)
    {
    array[i] = (int)(Math.random()*100);
    }

    Sort sort = new Sort(array);
    sort.insertSort();
    System.out.println("The array after sorted");
    for(int i =0; i < size; i++)
    {
    System.out.print(array[i] + " ");
    } }}
    编译的最终结果是找不到文件.
    以上代码在eclipse里编译调试可通过