Mercurial > hg > Applications > Grep
comparison c/bitVector/main.cc @ 49:f76fe618d5a7
implement bitset
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 25 May 2015 20:46:26 +0900 |
parents | 010ae96a3e4e |
children | bb0e88fbbe02 |
comparison
equal
deleted
inserted
replaced
48:010ae96a3e4e | 49:f76fe618d5a7 |
---|---|
1 #include <stdio.h> | 1 #include <stdio.h> |
2 #include <stdlib.h> | |
3 #include <string.h> | |
2 | 4 |
3 int main(int argc, char *argv[]){ | 5 unsigned long bitContainer = 0x0000000000000000; |
6 unsigned long bitMask = 0xFFFFFFFFFFFFFFFF; | |
4 | 7 |
8 void bitSet(unsigned int bitShiftNum) { | |
9 bitContainer = 1 ; | |
10 bitContainer = bitContainer << (63 - bitShiftNum); | |
11 | |
12 for (int i = 63; i >= 0; i--) { | |
13 printf( "%lu", ( bitContainer >> i ) & 1 ); | |
14 } | |
15 puts(""); | |
16 } | |
17 | |
18 void bitGet() { | |
19 | |
20 } | |
21 | |
22 int main(int argc, char **argv) { | |
23 | |
24 unsigned int bitShiftNum = 0; | |
25 for (int i = 1; i < argc ; i++) { | |
26 if (strcmp(argv[i],"-n") == 0) { | |
27 bitShiftNum = atoi(argv[i+1]); | |
28 } | |
29 } | |
30 | |
31 bitSet(bitShiftNum); | |
5 return 0; | 32 return 0; |
6 } | 33 } |