import java.util.Scanner;
class Main{
public static void main(String args[]){
int i,j,min,loc,temp,number=8;
int list[]=new int[number];
Scanner input=new Scanner(System.in);
for(i=0;i<number;i++){
System.out.println("Enter the numbers ");
list[i]=input.nextInt();
}
min=list[0];
for(i=0;i<=number-1;i++){
min=list[i];
loc=i;
for(j=i+1;j<=number-1;j++){
if(list[j]<min){
min=list[j];
loc=j;
}
}
if(loc!=i){
temp=list[i];
list[i]=list[loc];
list[loc]=temp;
}
}
for(i=0;i<=number-1;i++){
System.out.println("Selection sorted list are
"+list[i]);
}
}
}
OUTPUT:-
C:\Users\saty\Desktop>javac 1.java
C:\Users\saty\Desktop>java Main
Enter the numbers
45
Enter the numbers
2
Enter the numbers
12
Enter the numbers
58
Enter the numbers
64
Enter the numbers
98
Enter the numbers
22
Enter the numbers
8
Selection sorted list are 2
Selection sorted list are 8
Selection sorted list are 12
Selection sorted list are 22
Selection sorted list are 45
Selection sorted list are 58
Selection sorted list are 64
Selection sorted list are 98
The best. This guy should teach "Teachers"
ReplyDeletejust beginned java today and your tutorial explained me the best
ReplyDeleteGod bless you! :) Finally something useful, and also explained for beginners!
ReplyDeleteThank you sir, you have done well! keep creating your greatness to assist the world.
ReplyDeleteExcellent Work. you have done a great job. this is easy to understand and it is very helpful in programming
ReplyDeleteThanks a lot for your tutorials! Much appreciated.
ReplyDeleteGreat teaching skills thank you so much!
ReplyDeletethank you sir...
i am also learning this ... its easy to understand ... thanks for the code ...
ReplyDelete