-5
나는 당신이 그것을 내가 쓴 6000 번 랜드() 함수는
을 던질 때 주사위의 각면의 수를 표시하는 프로그램을 구축하고자 랜드() 함수에 문제가 제대로 작동하지 않습니다 코드#include <iostream>
using namespace std;
#include <iomanip>
using std::setw;
#include <cstdlib>
#include <ctime>
int main()
{
int face ;
int frequency1 =0;
int frequency2 =0;
int frequency3 =0;
int frequency4 =0;
int frequency5 =0;
int frequency6 =0;
for(int counter =1;counter <=6000;counter++){
face = 1+rand()%6;
switch(face){
case 1:
++frequency1;
break;
case 2:
++frequency1;
break;
case 3:
++frequency1;
break;
case 4:
++frequency1;
break;
case 5:
++frequency1;
break;
case 6:
++frequency1;
break;
default:
cout<<"program should never get here!!! ";
break;
}}
cout<<"the number of face 1 is : "<<frequency1<<endl;
cout<<"the number of face 2 is : "<<frequency2<<endl;
cout<<"the number of face 3 is : "<<frequency3<<endl;
cout<<"the number of face 4 is : "<<frequency4<<endl;
cout<<"the number of face 5 is : " <<frequency5<<endl;
cout<<"the number of face 6 is : " <<frequency6<<endl;
return 0;
}
내가 그것을
the number of face 1 is : 6000
the number of face 2 is : 0
the number of face 3 is : 0
the number of face 4 is : 0
the number of face 5 is : 0
the number of face 6 is : 0
항상 'frequency1'에 추가하고 있습니다. 무엇을 기대합니까? – Li357
또한 깃발거에게는 반드시 중복되는 것은 아닙니다. 인쇄 상 오류가 있습니다. – Li357
@AndrewL 아, 당신은 절대적으로 맞습니다. [단 한 손으로 그런 질문을 끝내기 위해서는 이러한 힘이 있어야합니다.] (http://meta.stackoverflow.com/questions/326250/would-it- m3 % c3 % b6lnir-close-voting-for-lang의 확장 기능을 유용하게 사용할 수 있습니다. –