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

您没有登录

» Java开发网 » Java SE 综合讨论区  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 冒泡排序算法的一个问题.进来看看
lsqily82





发贴: 6
积分: 0
于 2006-02-23 22:49 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
public class Bubble
{
  public static void main(String args[])
  {
  
    int array[]= {55,2,6,4,32,12,-9,73,26,37};
    System.out.println("数据原始顺序:"+args[0]);
    
   for (int i=0;i<array.length;i++)
   {
     System.out.print(args[i]+"\t");
   }
   Bubble b=new Bubble();
   int[] result =b.bubble(array);
    
    
     System.out.println("\n\n排序后:");
     for(int i=0;i<result.length;i++)
     {
       System.out.print(result[i]+"\t");
     }
     }
    public int[] bubble(int a[])
    {
      int temp,size=a.length;//外层循环
      for (int i=size-1;i>=1;i--)
      {
        boolean end =true;
        //内层循环
        for(int j=0;j<i;j++)
        {
          if(a[j]>a[j+1])
          {
            temp=a[j];
            a[j]=a[j+1];
            a[j+1]=temp;
            end =false;
          }
        }
        if(end==true){
        break;
      }
    }
      return a;
    }
       
    }
我这样编译可以,但我不知道要怎么写才能实现键盘输入一组数字.然后输出排序后的结果,请各位高手帮忙一下.不胜感谢.我是新手,




话题树型展开
人气 标题 作者 字数 发贴时间
7066 冒泡排序算法的一个问题.进来看看 lsqily82 894 2006-02-23 22:49
5726 Re:冒泡排序算法的一个问题.进来看看 whiye 52 2006-02-25 09:31
5634 Re:冒泡排序算法的一个问题.进来看看 tzutolin 73 2006-02-25 10:03
5385 Re:冒泡排序算法的一个问题.进来看看 mliwng 181 2006-03-19 19:02
5348 Re:冒泡排序算法的一个问题.进来看看 jackyangf 7 2006-03-20 17:50
5984 Re:冒泡排序算法的一个问题.进来看看 heartache 16 2006-03-23 14:44
5604 Re:冒泡排序算法的一个问题.进来看看 j2eesir 51 2006-03-24 10:05

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