这个选择排序吗? [英] Is this selection sort ?

查看:109
本文介绍了这个选择排序吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

package sorting;
public class selection_sort
{
    public static void main(String[] args) 
    {  
    int x[] = { 23 , 24 , 87 , 12 , 2 , 1 } ;  
    int i , j ;
    
int l ;
int c ;

for ( i =0 ; i<=4  ; i++ )   
{
    
for ( j = i ; j<=4 ; j++ )     
{
     
   if (x[i] > x[j+1] )
   {
   c= x[i];
   x[i]=x[j+1] ;       
    x[j+1] = c ;
   
   } 
}

    System.out.println();
System.out.println(" after stage " + (i+1) + " array is ") ;
    System.out.println();
        
for ( int k =0 ; k<=5 ; k++)
{
    System.out.print(x[k] + "   ");
}

    System.out.println();
    }
     
System.out.println(" FINALLY SORTED ARRAY IS : ");
for ( int k =0 ; k<=5 ; k++)
{
    System.out.print(x[k] + "   ");
}
    }
   
}







这是一个选择程序吗?



我尝试过:



我在netbeans IDE上运行了这个。




Is this a program of selection sort ?

What I have tried:

I have run this on netbeans IDE .

推荐答案

选择排序 - Google搜索 [ ^ ]。


Nope,即冒泡排序 [ ^ ]。
Nope, that is bubble sort[^].


这篇关于这个选择排序吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆