看板java
标 题Re: [问题] Selection Sorting的问题
发信站无名小站 (Sun May 14 21:33:27 2006)
转信站ptt!ctu-reader!Spring!news.nctu!news.ntu!news.ee.ttu!netnews.csie.nctu
Don't fed up.
Are you using IDE to compile and running your code?
If that so, it could probably your IDE problem
on caching to the old version class file.
I have had facing this problem before.
The solution is delete the destination class file
where your source compile to and recompile it again.
Good luck :)
※ 引述《[email protected] (PP)》之铭言:
> 这就怪了...
> 只有我电脑有问题吗?@@
> 迷惘了...
> 难怪我讨厌写JAVA...
> 真奇怪..
> 那我贴另一个相似的好了...
> 这个应该就有问题了吧...
> (还是压根儿是我电脑不好...)
> import java.io.BufferedReader;
> import java.io.IOException;
> import java.io.InputStreamReader;
> import java.util.Random;
> public class Bubble {
> private int bubbleArr[];
> private int selectArr[];
> private int max=100;
> public void Select(int n){
> selectArr = new int[n];
> getRndNum();
> }
> public void Select(int n,int m){
> selectArr = new int[n];
> max=m;
> getRndNum();
> }
> public Bubble(int n){
> bubbleArr = new int[n];
> getRndNum();
> }
> public Bubble(int n,int m){
> bubbleArr = new int[n];
> max=m;
> getRndNum();
> }
> private void getRndNum(){
> Random rand=new Random();
> for (int i=0;i<bubbleArr.length-1;i++){
> bubbleArr[i]=rand.nextInt(max);
> }
> }
> public void showArray(){
> for (int i=0;i<bubbleArr.length;i++){
> System.out.print(bubbleArr[i]+" ");
> }
> System.out.println("");
> }
> public void bubbleSort(){
> int q=0;
> for (int x=1;x<=bubbleArr.length-1;x++){
> for (int i=1;i<=bubbleArr.length-1;i++){
> if (bubbleArr[i-1]>bubbleArr[i]){
> q=bubbleArr[i-1];
> bubbleArr[i-1]=bubbleArr[i];
> bubbleArr[i]=q;
> }
> }
> }
> }
> public void selectSort(){
> int tempArr[];
> int x=0;
> int s=0;
> tempArr= new int[selectArr.length];
> for (x=1;x<selectArr.length-1;x++){
> for (int i=1;i<selectArr.length-1;i++){
> if (tempArr[x-1]<selectArr[i-1]){
> tempArr[x-1]=selectArr[i-1];
> s=i-1;
> }
> }
> selectArr[s]=-1;
> }
> selectArr = tempArr;
> }
> public static void main(String[] args) {
> BufferedReader in=new BufferedReader(
> new InputStreamReader
> (System.in));
> String str="";
> try {
> str=in.readLine();
> } catch (IOException e) {
> e.printStackTrace();
> }
> int n= Integer.parseInt(str);
> Bubble myBub1=new Bubble(n);
> myBub1.showArray();
> myBub1.bubbleSort();
> myBub1.showArray();
> Bubble mine=new Bubble(n);
> mine.showArray();
> mine.selectSort();
> mine.showArray();
> }
> }
> 很类似..不过多了个BUBBLE
> 内容很多...有点小抱歉@@
> 谢谢
> ※ 编辑: sonicno111 来自: 218.165.38.124 (05/14 17:33)
--
夫兵者不祥之器物或恶之故有道者不处君子居则贵左用兵则贵右兵者不祥之器非君子
之器不得已而用之恬淡为上胜而不美而美之者是乐杀人夫乐杀人者则不可得志於天下
矣吉事尚左凶事尚右偏将军居左上将军居右言以丧礼处之杀人之众以哀悲泣之战胜以
丧礼处之道常无名朴虽小天下莫能臣侯王若能守之万物将自宾天地相合以降甘露民莫
之令而自均始制有名名亦既有夫亦将知止知止可以不殆譬道之在天下犹 tm.net.my海