-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathset.c
More file actions
54 lines (46 loc) · 881 Bytes
/
set.c
File metadata and controls
54 lines (46 loc) · 881 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
49
50
51
52
53
54
#include <stdio.h>
#include "set.h"
void union_set(char *set1, char *set2, char *set3)
{
int i;
for (i=0; i<ARRAY; i++)
set3[i] = set1[i] | set2[i];
}
void intersect_set(char *set1, char *set2, char *set3)
{
int i;
for (i=0; i<ARRAY; i++)
set3[i] = set1[i] & set2[i];
}
void sub_set(char *set1, char *set2, char *set3)
{
int i;
for (i=0; i<ARRAY; i++)
set3[i] = set1[i] & ~set2[i];
}
void print_set(char *mySet)
{
int i,j,b;
unsigned char temp;
for (i=b=0;i<ARRAY ;i++ )
{
temp = mySet[i];
for ( j=0;j<BYTE ;j++, b++, temp >>= 1)
if (temp & 01)
printf("%d ", b);
}
printf("\n");
return;
}
int read_set(char *mySet, int num)
{
unsigned char temp;
char seg, dig, i;
dig = num % BYTE;
seg = num / BYTE;
temp = 01;
for (i=0; i<dig ;i++ )
temp <<= 1;
mySet[seg] |= temp;
return 0;
}