TheAlgorithms/C++
1.0.0
All the algorithms implemented in C++
Loading...
Searching...
No Matches
shell_sort.cpp
1
#include <iostream>
2
3
int
main
() {
4
int
size = 10;
5
int
* array =
new
int
[size];
6
// Input
7
std::cout <<
"\nHow many numbers do want to enter in unsorted array : "
;
8
std::cin >> size;
9
std::cout <<
"\nEnter the numbers for unsorted array : "
;
10
for
(
int
i = 0; i < size; i++) {
11
std::cin >> array[i];
12
}
13
14
// Sorting
15
for
(
int
i = size / 2; i > 0; i = i / 2) {
16
for
(
int
j = i; j < size; j++) {
17
for
(
int
k = j - i;
k
>= 0;
k
=
k
- i) {
18
if
(array[k] < array[k + i]) {
19
break
;
20
}
else
{
21
int
temp = array[
k
+ i];
22
array[
k
+ i] = array[
k
];
23
array[
k
] = temp;
24
}
25
}
26
}
27
}
28
29
// Output
30
std::cout <<
"\nSorted array : "
;
31
for
(
int
i = 0; i < size; ++i) {
32
std::cout << array[i] <<
"\t"
;
33
}
34
35
delete
[] array;
36
return
0;
37
}
numerical_methods::simpson_method::k
double k(double x)
Another test function.
Definition
composite_simpson_rule.cpp:117
main
int main()
Main function.
Definition
generate_parentheses.cpp:110
sorting
shell_sort.cpp
Generated by
1.12.0