Facebook
Banner
XMPP JavaScript Library READ MORE

Selection Sort


1 #include <stdio.h>
2
3 void selectionSort(int list[],int size){
4 int temp=0,min=0;
5
6 for(int i=0; i<size-1; i++){
7 min=i;
8 for(int j=i+1; j<size; j++){
9 if(list[j]<list[min])
10 min=j;
11 }
12 temp=list[i];
13 list[i]=list[min];
14 list[min]=temp;
15 }
16 }
17
18 void printArray(int list[],int size){
19 for(int i=0; i<size; i++){
20 printf("%d",list[i]);
21 }
22 }
23
24 int main(){
25 int nums[5]={5,4,3,2,1};
26 selectionSort(nums,5);
27 printArray(nums,5);
28
29 return 1;
30 }
Add Your Comment
   
    Yes! I want to receive all comments by email

  by jas wedding potographers on 08-Jul-2019 03:42 pm
I am appreciative for the blog article
  • Reply
  •  0 Like
  •  0 Dislike
  • Report
  by sarvesh wedding photographers on 08-Jul-2019 03:41 pm
You make it enjoyable and you still take care of to keep it wise
  • Reply
  •  0 Like
  •  0 Dislike
  • Report