소수첫쨰자리 출력방법 및 디버깅 도와주세욧
희미햬
질문 제목 :
소수첫쨰자리 출력방법 및 디버깅 도와주세욧
오류가 6개가 나오는데 미치것네요~
디버깅좀 해주세용 ㅠㅠ아 그리구 결과값이 실수가 나오는데 소수 첫째자리 까지만 나오게 하려면 어떻게 해야하는지요?
소주자리수 (0.1) 이렇게요~ 도와주세용질문 내용 :
#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; //0~9 까지의 숫 자가 랜담하게 발생(rand()%10000+1)/100.0
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 ) // 2,3 ( 2/10)
nresultnum = 2;
else if(nrandnum ==4 || nrandnum == 5 ) // 4,5 ( 2/10)
nresultnum = 3;
else if(nrandnum ==6) // 6( 1/10)
nresultnum = 4;
else if(nrandnum ==7) // 7( 1/10)
nresultnum = 5;
else if(nrandnum ==8 || nrandnum == 9) // 7( 1/10)
nresultnum = 6;
if(nresultnum -1)//나온 숫자 빈도 증가
arrrandtotalnum[nresultnum]++;
}
for(int j = 0; j 7; j++)
printf( %d이 나온 빈도 = %d\n, j,arrrandtotalnum[j]);
return 0;
}
컴파일시 오류가 6개 뜨는데 디버깅좀 도와주시구요~
소수 첫째자리로 출력해야되는데 수정좀 부탁드립니다.