-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.c
53 lines (48 loc) · 1.01 KB
/
test.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
/*
* test
*/
#include "uarray2.h"
#include "bit2.h"
void modify(Bit2_T bit2)
{
printf("modify\n");
assert(bit2);
for (int row = 0; row < Bit2_height(bit2); row++)
for (int col = 0; col < Bit2_width(bit2); col++)
if ((col + row) % 2 == 0)
Bit2_put(bit2, col, row, 1);
return;
}
void print (int col, int row, int bit, void *cl)
{
printf("(%d, %d):", col, row);
printf("%-3d", bit);
int *i = (int *)cl;
if (col == *i - 1)
printf("\n");
return;
}
int main(int argc, char *argv[])
{
(void) argv;
(void) argc;
/*
UArray2_T myarray = UArray2_new (1, 4 , 1);
UArray2_free(&myarray);
*/
int w = 0, h = 0;
printf("enter the width:");
scanf("%d", &w);
printf("enter the height:");
scanf("%d", &h);
Bit2_T myBit2 = Bit2_new(w, h);
Bit2_map_row_major(myBit2, print, &w);
modify(myBit2);
/*
Bit2_get(myBit2, 9, 3);
*/
Bit2_map_row_major(myBit2, print, &w);
printf("ones in bit2: %d\n", Bit2_count(myBit2));
Bit2_free(&myBit2);
return 0;
}