-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patha.cpp
More file actions
48 lines (30 loc) · 613 Bytes
/
a.cpp
File metadata and controls
48 lines (30 loc) · 613 Bytes
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
#include <stdio.h>
#include <stdlib.h>
void ShellSort(int array[], int size){
int Increase=size/2;
int i,j, temp;
while(Increase!=0){
for(i=Increase; i<size; i++){
temp = array[i];
j=i-Increase;
while(j>=0 && temp<array[j]){
array[j+Increase] = array[j];
array[j] = temp;
j-=Increase;
}
}
Increase=Increase/2;
}
}
void print(int array[], int size){
for(int i=0; i<size;i++){
printf("%d ", array[i]);
}
}
int main(){
int array[] = {5,6,9,4,1,-9,-8,6,50};
int size = sizeof(array)/sizeof(array[0]);
ShellSort(array, size);
print(array, size);
return 0;
}