Skip to content

Commit

Permalink
Merge pull request #799 from webdesignerrps/patch-2
Browse files Browse the repository at this point in the history
Create select.java
  • Loading branch information
tanus786 committed Oct 29, 2022
2 parents 92a3cca + 23f2e0b commit 3727162
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions Java/sorting techniques/selection
@@ -0,0 +1,50 @@
import java.util.Scanner;

public class SelectionSortExample2
{
public static void main(String args[])
{
int size, i, j, temp;
int arr[] = new int[50];








Scanner scan = new Scanner(System.in);

System.out.print("Enter Array Size : ");
size = scan.nextInt();

System.out.print("Enter Array Elements : ");
for(i=0; i<size; i++)
{




arr[i] = scan.nextInt();
}

System.out.print("Sorting Array using Selection Sort Technique..\n");
for(i=0; i<size; i++)
{for(j=i+1; j<size; j++)
{ if(arr[i] > arr[j])
{
temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
}
}

System.out.print("Now the Array after Sorting is :\n");
for(i=0; i<size; i++)
{
System.out.print(arr[i]+ " ");
}
}
}

0 comments on commit 3727162

Please sign in to comment.