1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
using std::cout; using std::cin; using std::endl; #include<iomanip> using std::setw; #include<cstdlib> #include<ctime> #include<cmath> int main() { const int arraysize=7; int frequency[arraysize]={0}; const int array2=6; double deviation[array2]={0}; int turn; int fresum=0; double mean_fre; double expect; cout<<"Enter number of roll:"; cin>>turn; expect=turn/6; srand(time(0) ); for (int i=1;i<=turn;i++) { ++frequency[1 + rand()%6]; } for (int j=0;j<=6;j++) { deviation[j]= (expect - frequency[j])/expect *100; } cout<<"FACE"<<setw(13)<<"FREQUENCY"<<setw(13)<<"DEVIATION"<<endl; cout << fixed << setprecision(3); for(int face=1;face<=6;face++) { cout<<setw(4)<<face<<setw(14)<<frequency[face]<<setw(13)<<deviation[face]<<"%"<<endl; } return main(); }