Re: [問題] Selection Sorting的問題
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 :)
※ 引述《sonicno111.bbs@ptt.cc (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海
討論串 (同標題文章)
完整討論串 (本文為第 15 之 15 篇):
java 近期熱門文章
PTT數位生活區 即時熱門文章