Lee_assig23a - j<12 j++) if (j==flipCoin()) counter[j]++...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 //Cheu Lee Assing 23 #include <iostream> #include <cmath> #include <ctime> #include <cstdlib> using namespace std int flipCoin(void) int main() { int n, counter[13]={0} srand(time(0)) cout<<"How many times do you want to do the experiment?"<<endl cin>>n for(int i=0 i<n i++){ for(int j=0
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: j<12 j++) if (j==flipCoin()) counter[j]++ } for(int i=0 i<=12 i++){ cout<<i<<": " for(int t=0 t<counter[i] t++){ cout<<"* " } cout<<endl } return 0 } int flipCoin (void){ int heads=0, a for (int i=0 i<12 i++){ a=rand() if (a%2==1) heads++ } return heads }...
View Full Document

This note was uploaded on 05/16/2010 for the course CISCO EST61 taught by Professor Miller during the Spring '10 term at Fresno City College.

Ask a homework question - tutors are online