From 5bcbeea329a54f9f054ff8f226d1b2df4d21a145 Mon Sep 17 00:00:00 2001 From: RossTheRoss Date: Sun, 24 Feb 2019 13:17:13 -0600 Subject: Finish 3A but 10s are hard --- ee1301/wk3/hw3_directory/strap012_HW3A.cpp | 37 +++++++++++++++++------------- 1 file changed, 21 insertions(+), 16 deletions(-) (limited to 'ee1301') diff --git a/ee1301/wk3/hw3_directory/strap012_HW3A.cpp b/ee1301/wk3/hw3_directory/strap012_HW3A.cpp index 55e8f6c..8d75294 100644 --- a/ee1301/wk3/hw3_directory/strap012_HW3A.cpp +++ b/ee1301/wk3/hw3_directory/strap012_HW3A.cpp @@ -17,10 +17,11 @@ using namespace std; int spin_the_wheel(int d, int w) { int spinOG=0, spinNew=0, win=0; - for (int i=1; i<=w; i++) { + //spinOG = ( (rand() % d) + 1); + for (int i=0; i0; n--) { + int test = spin_the_wheel(d, w); + m+=test; + } + double win=m; + cout << fixed << setprecision(5) + << "w=" << w << ", d=" << d + << ": Simulated probability = m/n = " << (win / 1000000.0) * 100.0 << "%. " + << "Theoretical probability = " << (d / (pow(d, w))) * 100 << "%." << endl; + d+=2; + } } - - cout << "w=" << w << ", d=" << d; - cout << ": Simulated probability = m/n = " << (m/n)*100 << "%. "; - cout << "Theoretical probability = " << (d/(pow(d,w)))*100 << "%." << endl; } \ No newline at end of file -- cgit v1.2.3