
{modify this proram in such a way so that it can take input int and char both .and also modify so that input can be given at run time.}
public class Insertion{
public static void main(String a[]){
int i;
int array[]={17,12,3,6,4,19,200};
System.out.println(" Selection Sort\n\n");
System.out.println("Values Before the sort:\n");
for(i = 0; i < array.length; i++)
System.out.print( array[i]+" ");
System.out.println();
insertion_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("PAUSE");
}
public static void insertion_srt(int array[],int n){
for (int j = 0; j < n; j++){
int i = j-1;
int k = array[j];
while ((i>= 0) && (array[i] > k)){
array[i+1]=array[i];
i=i-1;
array[i+1]=k;
}}
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.