비트열추력문제입니다 조언구합니당.
뿌잉
질문 제목 : 비트열로 출력비트열로 출력하는 문제인데 수정좀 부탁드릴게요질문 내용 :
#includestdio.h
#includestdlib.h
#includetime.h
#define rand_max
int main(int argc, char* argv[])
{
int arrrandtotalnum[7] = {0,}; //0~6
srand( time(null) );
int nrandnum = rand() %rand_max;
int nresultnum = -1;
for(int i = 0; i rand_max; i++)
{
nrandnum = rand() %rand_max;
nresultnum = -1;
//1+1+2+2+1+1+2 = 10
if(nrandnum == 0 ) // 0( 1/10 )
nresultnum = 0;
else if(nrandnum == 1 ) //1( 1/10)
nresultnum = 1;
else if(nrandnum ==2 || nrandnum == 3 )
nresultnum = 2;
else if(nrandnum ==4 || nrandnum == 5 )
nresultnum = 3;
else if(nrandnum ==6)
nresultnum = 4;
else if(nrandnum ==7)
nresultnum = 5;
else if(nrandnum ==8 || nrandnum == 9)
nresultnum = 6;
if(nresultnum -1)
arrrandtotalnum[nresultnum]++;
}
for(int j = 0; j 7; j++)
printf( %d이 나온 빈도 = %d\n, j,arrrandtotalnum[j]);
return 0;
}
이 소스 문에서 출력되는수를 비트열로 바꾸고 싶은데요 도와주세요
예를 들어 12가 나왔는데 이것을 비트열로 출력하고 싶다 하면 1100 이런식인거죠,
도와주세요