Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java SE 综合讨论区 » Java与OOP初步  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 Re:给一个数组从小到大排列的问题 [Re:8261669]
wwhui





发贴: 10
积分: 0
于 2006-09-11 23:16 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
//给你一个最简单的,选择排序的完整程序,你参考一下。
import java.io.*;
public class sy1
{public static void main(String args[])
  {int a[]={32,87,3,589,12,1076,2000,8,622,127},n=10;
   px(a,n);
   System.out.println("排序后的情况:");
   for(int j=0;j<10;j++)
   System.out.print(" "+a[j]+" ");
    }
    
    
  static void px(int arr[],int n)
  {int temp,p;
   for(int i=0;i<n-1;i++)
   {p=i;
     for(int j=i+1;j<n;j++)
      if(arr[p]>arr[j])
       p=j;
      if(p!=i)
       {temp=arr[p];arr[p]=arr[i];arr[i]=temp;}
   }   
  }  
  
}




话题树型展开
人气 标题 作者 字数 发贴时间
13511 给一个数组从小到大排列的问题 8261669 124 2006-09-05 21:30
11452 Re:给一个数组从小到大排列的问题 lisliefor 77 2006-09-05 22:11
11841 Re:给一个数组从小到大排列的问题 wwhui 501 2006-09-11 23:16
11415 Re:给一个数组从小到大排列的问题 8261669 9 2006-09-05 22:17
11649 Re:给一个数组从小到大排列的问题 lwfllr 224 2006-09-06 00:56
11307 Re:给一个数组从小到大排列的问题 why 34 2006-09-06 11:45
11882 Re:给一个数组从小到大排列的问题 fragking888 611 2006-09-07 17:50
11286 Re:给一个数组从小到大排列的问题 yzcj007 235 2006-09-08 09:04
11161 Re:给一个数组从小到大排列的问题 leange 34 2006-09-09 15:28
11221 Re:给一个数组从小到大排列的问题 8261669 290 2006-09-09 20:57
11255 Re:给一个数组从小到大排列的问题 lisliefor 90 2006-09-11 10:52

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923