看板java
标 题Re: [问题] Selection Sorting的问题
发信站梦之大地 (Sun May 14 13:49:51 2006)
转信站ptt!ctu-reader!ctu-peer!news.csie.ncyu!news.cs.nthu!netnews.csie.nctu!
看这样子很像是你的Scope没做好
你的selectArr确定是一个全区变数吗?
※ 引述《[email protected] (PP)》之铭言:
> 我贴一下现在的进度
> 只贴了执行SORTING那部份
> 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;
> }
> 这样子有没有不对劲阿?@@
> (selectArr是之前就有设的阵列_
> 每次都说tempArr= new int[selectArr.length];这行出问题?
> java.lang.NullPointerException....这句不懂>/////<
> 另外...可不可以请教一下取乱数该用哪种rand的比较好呢?@@
> 谢谢
> 另外...还有有没有其他可以不用让selectArr[s]变成-1而让他消失的方法?@@
> 每次都要再检查那个-1好像是一种浪费...
> ※ 编辑: sonicno111 来自: 218.165.38.124 (05/14 13:37)
--
"To learn is what I need; "学习是我所须;
to teach those who needs 教导那些想要
to learn is my duty ..." 学习的是我的使命..."
--
◢◣ ︵︵ █▔◣ █▔█ █▔▔ █▔█ █▆▉ █ █▔█ █◣█ █▔●
◢◤█◣◢◣ ︵︵ █ █ █▁◤ █▁▁ █▁█ ▉▉▉ █ █▁█ █◥█ █ █
梦之大地 逼逼ㄟ四 █▁◤ █ █ █▁▁ █ █ ▉▉▉ █▁ █ █ █ █ █▁◤
※ Origin: <bbs.ccns.ncku.edu.tw> ◆ From: 140.116.116.76