-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathselectionsort.c
59 lines (43 loc) · 1.07 KB
/
selectionsort.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <stdio.h>
void selectionsort(int data[100], int size){
int temp=0;
int min=0;
for(int i = 0 ; i < size -1; i++){
min =i;
for(int j= i+1; j < size; j++){
if(data[j] < data[min]){
temp = data[j];
data[j]= data[min];
data[min]= temp;
}
}
}
printf("\n");
printf("\t[!]The sorted array is : \n");
for(int x =0 ; x < size; x++){
printf("%d\n",data[x]);
}
printf("\n");
}
int main()
{
int arr[100];
int size;
banner();
printf("[!] Enter The size of the array you want so sorted :");
scanf("%d",&size);
for(int i =0 ; i < size ; i ++){
printf("\t\t\tEnter Number (%d) ==> ",i+1);
scanf("%d",&arr[i]);
}
selectionsort(arr,size);
}
void banner()
{
printf("\n");
printf("-------------------------------------------------------------------------------\n");
printf("\t\t\tSelection sort Algorithem Using C\n");
printf("\t\t\t\tCoded By D4az\n");
printf("-------------------------------------------------------------------------------\n");
printf("\n");
}