Commit f220fe57 by PotatoGim

C++ 비트 세기 예제 및 디렉터리 재명명

parent 4a3f2236
/*!
*============================================================================
* @file count_bits_with_bitset_n_limits.cxx
* @author Ji-Hyeon Gim (potatogim@potatogim.net)
* @version 1.0
* @brief
* @date 2015년 01월 29일 14시 39분 48초
* @copyright GNU General Public License
* Organization
* Compiler g++
*============================================================================
*/
#include <iostream>
#include <bitset>
#include <limits>
#include <stdio.h>
int
count_bits (const char n)
{
std::bitset<std::numeric_limits<unsigned char>::digits> c(n);
return c.count();
}
int
main (int argc, char *argv[])
{
std::cout << "Number : "
<< std::bitset<std::numeric_limits<unsigned char>::digits> ('a')
<< '\n';
std::cout << "Num of bits : " << count_bits('a') << '\n';
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment