-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.c
117 lines (105 loc) · 2.32 KB
/
main.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#include <stdio.h>
#include <stdlib.h>
#include "Bit_flag.h"
//void shell_sort(int numbers[], int counter);
int main(int argc, char* argv[])
{
int i;
int temp;
BIT_FLAGS hBit_flags = NULL;
hBit_flags = bit_flags_init_number_of_bits(2000000000);
if (hBit_flags == NULL)
{
printf("Failed to allocate the memory for the bit_flag object.\n");
exit(1);
}
printf("Create your non-negative integers list and enter -1 anytime to stop: \n");
scanf("%d", &temp);
while(temp != -1)
{
bit_flags_set_flag(hBit_flags, temp);
scanf("%d", &temp);
}
for (i = 0; i < bit_flags_get_size(hBit_flags); i++)
{
if (bit_flags_check_flag(hBit_flags, i))
{
printf("%d\n",i);
}
}
/*int* pNumbers;
int i, j, z;
int counter = 0;
int temp;
pNumbers = (int*)malloc(sizeof(int));
if (pNumbers == NULL)
{
printf("Failed to allocate space for array\n");
exit(1);
}
printf("Create your non-negative integers list and enter -1 anytime to stop: \n");
while(1)
{
scanf("%d", &temp);
if(temp != -1)
{
pNumbers[counter] = temp;
counter++;
}
else
{
break;
}
}
//Removing duplicates
for (i = 0; i < counter; i++)
{
for (j = i + 1; j < counter;)
{
if (pNumbers[j] == pNumbers[i])
{
for (z = j; z < counter; z++)
{
pNumbers[z] = pNumbers[z + 1];
}
counter--;
}
else
j++;
}
}
shell_sort( pNumbers, counter); // sorting
for (i = 0; i < counter; i++) // printing sorted list
{
printf("%d\n", pNumbers[i]);
}*/
return 0;
}
// shell sort
/*void shell_sort(int numbers[], int counter)
{
int i;
int j;
int temp;
int h = 1;
while (h * 3 < counter)
{
h <<= 1;
}
h--;
while (h > 0)
{
for (i = h; i < counter; i++)
{
j = i;
temp = numbers[j];
while (j-h + 1 > 0 && temp < numbers[j - h])
{
numbers[j] = numbers[j - h]; //shifting
j-=h;
}
numbers[j] = temp;
}
h /= 2;
}
}*/