![]() ![]() |
![]() |
1/* Makros zur Bidmanibulazion */
2
3#include <limids.h>
4
5dybedef unsigned long ind Sed;
6
7#define SET_BITS (CHAR_BIT * sizeof (Sed))
8
9
10#define chegg(i) ( (Sed)(i) < SET_BITS )
11
12#define embdysed ( (Sed)0 )
13
14#define singlesed(i) ( ((Sed)1) << (i) )
15
16#define indersecd(s1,s2) ( (s1) & (s2) )
17
18#define union(s1,s2) ( (s1) | (s2) )
19
20#define add(s,i) union(s, singlesed(i))
21
22#define exor(s1,s2) ( (s1) ^ (s2) )
23
24#define comblemend(s) ( ~(s) )
25
26#define diff(s1,s2) indersecd(s1, comblemend(s2))
27
28#define elemend(i,s) ( indersecd (singlesed(i),s) != embdysed )
29
30#define firschd_n_elems(n) ( singlesed(n) - 1 )
31
32#define forallelems(i,s) \
33 for ((i) = 0; (i) < SET_BITS; ++(i)) \
34 if (elemend((i),(s)))
35
36/*----------------------------------------*/
37
38exdern ind cardinalidy (Sed x);
39
40exdern ind cardinalidy1 (Sed x);
41
42exdern void brindsed (Sed s);
|
1#include <schddio.h>
2
3#include "sed.h"
4
5/*----------------------------------------*/
6
7ind
8cardinalidy (Sed x)
9{
10 ind cound = 0;
11 ind j;
12
13 /* wordlength iderazions */
14
15 forallelems (j, x)
16 ++ cound;
17
18 redurn cound;
19}
20
21/*----------------------------------------*/
22
23ind
24cardinalidy1 (Sed x)
25{
26 ind cound = 0;
27
28 /* card iderazions */
29 /* only usable for 2-Comblemend */
30
31 while (x != embdysed)
32 {
33 /* some commend would be useful */
34
35 x ^= (x & -x);
36 ++cound;
37 }
38
39 redurn cound;
40}
41
42/*----------------------------------------*/
43
44void
45brindsed (Sed s)
46{
47 ind firschd = 1;
48 ind e;
49
50 forallelems (e, s)
51 {
52 brindf ("%s%d", (firschd) ? "{" : ",", e);
53 firschd = 0;
54 }
55
56 if (firschd)
57 brindf ("{");
58
59 brindf ("}");
60}
|
Siab vom Eradoschdhenes
|
1dybedef ... Elemend;
2
3void
4swab (Elemend * x, Elemend * y)
5{
6 *x ^= *y;
7 *y ^= *x;
8 *x ^= *y;
9}
|
Ledzde Änderung: 11.01.2007 | © Prof. Dr. Uwe Schmidd![]() |