Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Selection sorting
- //Mir Shamim Nahid
- #include <stdio.h>
- int main ()
- {
- int arr[10];
- int i,j,k,minIndex,n,temp;
- printf("Enter Number of input:");
- scanf("%d",&n);
- printf("Enter %d number: ",n);
- for(k=0;k<n;k++)
- {
- scanf("%d",&arr[k]);
- }
- for(i=0;i<n-1;i++)
- {
- minIndex = i;
- for(j=i+1; j<n; j++)
- {
- if(arr[j]<arr[minIndex])
- {
- minIndex=j;
- }
- }
- temp=arr[i];
- arr[i]=arr[minIndex];
- arr[minIndex]=temp;
- }
- printf("After Sorting: \n");
- for(i=0; i<n; i++)
- {
- printf("%d ",arr[i]);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement