import java.util.Scanner;
class Main{
public static void main(String args[]){
int i,j,n,k,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();
}
for(k=1;k<=number-1;k++){
temp=list[k];
j=k-1;
while((temp<list[j])&&(j>=0)){
list[j+1]=list[j];
j=j-1;
}
list[j+1]=temp;
}
for(i=0;i<number;i++){
System.out.println("Insertin sorted elements are
"+list[i]);
}
}
}
OUTPUT:-
C:\Users\saty\Desktop>javac
1.java
C:\Users\saty\Desktop>java
Main
Enter
the numbers
12
Enter
the numbers
42
Enter
the numbers
5
Enter
the numbers
8
Enter
the numbers
65
Enter
the numbers
1
Enter
the numbers
18
Enter
the numbers
9
Selection
sorted list are 1
Selection
sorted list are 5
Selection
sorted list are 8
Selection
sorted list are 9
Selection
sorted list are 12
Selection
sorted list are 18
Selection
sorted list are 42
Selection
sorted list are 65
good..
ReplyDeleteYou sir, are the best tutor!
ReplyDeleteThanks a million sir making my start a Wonderful Start.
ReplyDeletei was much worried about java learning but after taking this lecture m feelng relaxed thanku
ReplyDeletethanks a lot sir
ReplyDeleteeasy to learn for Beginners
Your teaching is highly organized and structured. Feeling lucky to find you. God bless you.
ReplyDeleteBeing a first year computer science student with no prior programming experience,I didn't understand anything in my university lectures and labs now everything is starting to make sense.
ReplyDeleteYou are the reason I want to be a programmer! Thank you so much!
ReplyDeleteReally helpful and simple ...
ReplyDeleteThanks man, this was helpful!
ReplyDelete