Datei: p4-8.c
1 /* 2 * p4-8.c 3 * Beispielprogramm 8, Abschnitt 4 4 * Zaehlt die Anzahl der 1-Bits in n, 5 * schnellere Variante 6 */ 7 8 int bitcount(unsigned int n) 9 { 10 int b; 11 12 b = 0; 13 while (n != 0) { 14 b++; 15 n = n & (n - 1); 16 } 17 return (b); 18 19 } /* bitcount() */
Erzeugt von c2html 1.01 |