Elite Coders Society
Hello Guest!
Join us here in this forum!
Please Log in or Register to access more feature in this site.
Start Learning!

† Copyright ©️ 2011 - EliteCoders.forums.ag †
Elite Coders Society
Hello Guest!
Join us here in this forum!
Please Log in or Register to access more feature in this site.
Start Learning!

† Copyright ©️ 2011 - EliteCoders.forums.ag †


Start sharing and learning new skills about programming and design by building connections with other professional and students.
 
HomeForumjava - Data Sorting: SelectionSort Java 2a512xyPortalLatest imagesGalleryjava - Data Sorting: SelectionSort Java Dw6hztSearchjava - Data Sorting: SelectionSort Java 2ns506pjava - Data Sorting: SelectionSort Java 2dt2b75RegisterLog in
Elite Coders Partner Links

EliteCoders™️ News!
Hello Guest!, Welcome in our forum. Be active!

Share | 
 

 Data Sorting: SelectionSort Java

View previous topic View next topic Go down 
AuthorMessage
Admin[dElmARk]
Admin[dElmARk]
Forum Owner
Forum Owner

Posts : 78
EC-Points : 6304
Thanked : 21
Join date : 15/10/2011
Age : 29
Location : Philippines

Hacker's Info
Hacking Exp:
java - Data Sorting: SelectionSort Java Left_bar_bleue0/0java - Data Sorting: SelectionSort Java Empty_bar_bleue  (0/0)
Hacker Type: White Hat
Hacking Title:

java - Data Sorting: SelectionSort Java Empty
PostSubject: Data Sorting: SelectionSort Java   java - Data Sorting: SelectionSort Java EmptyTue Nov 29, 2011 9:34 am

SelectionSort Java

Code:
public class SelectionSort
{
 public static void main(String A[])
 {
  int i;
  int array[]={12,9,4,99,120,1,3,10};
  System.out.println("Values Before the sort:");
  for(i=0; i<array.length; i++)
    System.out.print(array[i]+" ");
    System.out.println();
    selection_srt(array, array.length);
    System.out.print("Values after the sort:\n");
    for(i=0; i<array.length; i++)
      System.out.print(array[i]+" ");
      System.out.println();
      System.out.println("End of the sort");
 }
 public static void selection_srt(int array[], int n)
 {
    for(int x=0; x<n; x++)
    {
      int index_of_min=x;
      for(int y=x; y<n; y++)
      {
        if(array[index_of_min]<array[y])
        {
          index_of_min=y;
        }
        int temp=array[x];
        array[x]=array[index_of_min];
        array[index_of_min]=temp;
      }
    }
    }
}

Activity:
Create a program that will interact with the user.

The program must do the following:
1. Ask the user "How many numbers will be sorted? "
2. Display the unsorted numbers.
3. Display the sorted numbers in ascending order.
4. Display the sorted numbers in descending order.
Back to top Go down
 

Data Sorting: SelectionSort Java

View previous topic View next topic Back to top 

 Similar topics

-
» Data Sorting: BubbleSort Java
» Data Sorting: InsertionSort Java
» Data Java.
» Compiling Java Program
» Cashier Java
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
Elite Coders Society :: Software Development :: Java Programming :: Java Programming-

Protected by Copyscape Duplicate Content Finder
Powered By EliteCoders™

Elite Coders Partner Links
GreyPhantomYour Link HereYour Link HereYour Link Here
Yahoo!GoogleFacebookForumotion