- 浏览: 443084 次
- 性别:
- 来自: 深圳
文章分类
- 全部博客 (158)
- J2SE (15)
- c/c++ (17)
- linux & ubuntu (20)
- js (18)
- algorithm (21)
- android (1)
- software (3)
- svn (1)
- db (6)
- other (19)
- css (5)
- go (1)
- html 5 (3)
- computer science (1)
- php (3)
- 创业 (8)
- EJB & jboss (1)
- TDD (1)
- jsp & servlet (2)
- http, tcp & ip (2)
- hibernate (1)
- json (1)
- 乐 (2)
- ps (2)
- netbeans (1)
- extjs (2)
- eclipse (4)
- 项目管理 (1)
- varnish (2)
- study abroad (1)
- python (1)
- erlang (1)
- math (1)
- shell (1)
- assembly (4)
- lucene (1)
- web (1)
- http (1)
- tcp & ip (1)
最新评论
-
yiguxianyun:
...
css li 不换行 -
stdayong:
...
netbeans 中使用 maven -
程序猿_星:
为啥会中文乱码啊
servlet 以 gzip 格式返回数据 -
huanhuan519:
感谢分享~
gdb 调试工具 -
heyl1234:
写过些js,对css还不熟。谢谢~
css li 不换行
bit array,use less memory to describe a set of int number,
example:
/** * use bit string to store int numbers,if char[n] = 1,then n is include,else n is not exclude, */ #include <stdio.h> // set a bit to 1,which indicate that a number is include, void setbit(char data[], int pos); // get a bit,1 = include,0 = exclulde, char getbit(char data[], int pos); // indicate the position of bit in byte[] struct bit_of_ints { int a; // byte's subscript char b; // position in a single byte,0 - 7, }; // get position struct by pos, struct bit_of_ints figure_bit_of_ints(int pos); int main() { int length = 100; // figure byte count int bytecount = (length >> 3) + (length % 8 == 0 ? 0 : 1); char data[bytecount]; int i; // init byte[] for (i = 0; i < bytecount; i++) { data[i] = 0; } // set bits for (i = 0; i < length; i++) { if (i % 10 == 0) { setbit(data, i); } } // get bits for (i = 0; i < length; i++) { if (getbit(data, i) != 0) { printf("%d,", i); } } printf("\n"); return 0; } struct bit_of_ints figure_bit_of_ints(int pos) { struct bit_of_ints boi; char b = pos % 8; boi.a = pos >> 3; switch (b) { case 0: boi.b = 0x80; break; case 1: boi.b = 0x40; break; case 2: boi.b = 0x20; break; case 3: boi.b = 0x10; break; case 4: boi.b = 0x08; break; case 5: boi.b = 0x04; break; case 6: boi.b = 0x02; break; case 7: boi.b = 0x01; break; default: break; } return boi; } void setbit(char data[], int pos) { struct bit_of_ints bis = figure_bit_of_ints(pos); data[bis.a] |= bis.b; } char getbit(char data[], int pos) { struct bit_of_ints bis = figure_bit_of_ints(pos); return data[bis.a] & bis.b; }
发表评论
-
c - linkedlist
2012-05-10 14:52 1080c - linkedlist store ordere ... -
c - word counter (binary-tree)
2012-05-09 14:17 1725c - word counter (binary-tree) ... -
c - pointer is also pass by value
2012-05-09 14:13 971c - pointer is also pass by ... -
find palindromic-prime in pi
2012-04-26 18:32 1847find palindromic-prime in pi ... -
c #define
2012-04-08 13:29 2104c #define macro substitu ... -
c static
2012-04-04 21:59 1237c static static external ... -
c extern
2012-04-04 21:53 1153c extern extern, used to de ... -
int to string by specified base
2012-04-03 22:15 1078int to string by specified base ... -
random select
2011-08-28 01:00 1205random select problem: ... -
sparse data structure - matrix
2011-08-18 20:03 1081sparse data structure sp ... -
max sub_sequence - c
2011-08-10 01:02 1073max sub_sequence - c /* ... -
binary search - c
2011-08-06 12:07 1090binary search - c (simple) ... -
linux c udp
2011-04-01 18:02 2091linux 下可用 c 进行 udp 通信,使用 server ... -
linux c tcp
2011-04-01 18:00 3062linux 下可用 c 进行 tcp 通信,使用 server ... -
gdb 调试工具
2011-02-21 17:20 3315gdb 调试工具 gdb 概 ... -
linkedlist - java 简单实现
2011-02-11 21:29 1592linked list 链表, - ... -
queue (用 java 简单实现)
2011-02-03 01:45 4048queue ------ 结构 线性存 ... -
Medians and Order Statistics (次序统计)
2011-01-03 14:36 2827Medians and Order Statistics - ... -
counting sort
2011-01-02 20:36 1563counting sort ------ counting ... -
quick sort
2011-01-01 20:26 1190quicksort ------ quicksort ove ...
相关推荐
# The defaults are appropriate for compiling a simple program such as this one # Specify where and how to install the program. Since we only have one file, # the helloworld executable, install it by...
of the array in use. This has been corrected. * The description about slashes in gitignore patterns (used to indicate things like "anchored to this level only" and "only matches directories") has...
[3043174] Docbook use of '_' build failure [3085140] Ia_arpl_Ew_Rw definition of error [3078995] ROL/ROR/SHL/SHR modeling wrong when dest reg is 32 bit [2864794] BX_INSTR_OPCODE in "cpu_loop" ...
Java array and NIO Buffer arguments (primitive types and pointers) as pointer-to-buffer Nested structures and arrays Wide (wchar_t-based) strings Native long support (32- or 64-bit as appropriate)...
Learn and use Python and PyGame to design and build cool arcade games. In Program Arcade Games: With Python and PyGame, Second Edition, Dr. Paul Vincent Craven teaches you how to create fun and simple...
Pointers to Structures 5.7 - Sample Programs 5.7.1 - Simple Variable Declarations 5.7.2 - Using Pointer Variables 5.7.3 - Single Dimension Array Access 5.7.4 - Multidimensional Array ...
7. **16-Bit fixup encountered in object file `<text>`** - **含义**: 在对象文件 `<text>` 中遇到了 16 位修复。 - **解决办法**: 确保所有使用的库都是 32 位版本。 8. **486/487 instructions not enabled*...
LibTomCrypt has been designed from the ground up to be very simple to use. It has a modular and standard API that allows new ciphers, hashes and PRNGs to be added or removed without change to the ...
Finally, please make sure everything has the same bitness: 32-bit and 64-bit modules do not mix under any circumstances. Manual Installation Simply put all the desired JAR files (opencv*.jar, ffmpeg...
All text search and sorting functions use current system locale, so localizing your program with SQLMemTable is a very simple task. - Unicode support. All the text operations work with multi-byte ...
bitsort.c -- Sort with bit vectors. sortints.cpp -- Sort using C++ STL sets. qsortints.c -- Sort with C library qsort. bitsortgen.c -- Generate random integers for sorting. Column 2: Test and ...
Length Arrays and alloca() Friends Exceptions Run-Time Type Information (RTTI) Casting Streams Preincrement and Predecrement Use of const Integer Types 64-bit Portability Preprocessor Macros 0 and ...
TRxTrayIcon component enables 32-bit applications to add static and animated icons to the Windows system tray. TRxClock, TSecretPanel, TRxDice, TRxCalculator, TStrHolder, TMRUManager, TRxWindowHook, ...
Modular Programming Modules Public and Private The extern Storage Class Headers The Body of the Module A Program to Use Infinite Arrays The Makefile for Multiple Files Using the Infinite Array ...
lookaside_src.zip A simple way to keep items such as COM instances 'warm' and available for reuse (3KB)<END><br>57,isarray_src.zip A simple templated array class. (2KB)<END><br>58,...
Array and string slicing Flexible 'collection' system for dealing with linked lists etc Low level pointer handling UTF16 strings The ability to 'Incbin' binary data and access it as easily as if ...
When using ranges, do not use interrupts, or use DBVM Added find what writes/access to the foundlist Autoassembler scriptblocks are now grouped when written to memory Added {$try}/{$except} to auto ...
These tests were done on a HP ML120G6 system with 12Gb Ram, 10k raid disk drives running Windows 2008 Server R2 64 bit. For a measure of relative performance to RaptorDb v1 I have included a 20 ...
集合了 所有的 Unix命令大全 ...telnet 192.168.0.23 自己帐号 sd08077-you0 ftp工具 192.168.0.202 tools-toolss ... 各个 shell 可互相切换 ksh:$ sh:$ csh:guangzhou% bash:bash-3.00$ ... 命令和参数之间必需用空格隔...
Perform bit-level operations. - **`&`:** Bitwise AND. - **`|`:** Bitwise OR. - **`^`:** Bitwise XOR. - **`~`:** Bitwise NOT. - **`** Left shift. - **`>>`:** Right shift. ##### Assignment Operators ...