Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create select.java #799

Merged
merged 1 commit into from Oct 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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]+ " ");
}
}
}