-
coins
how to simulating a coins that turn and randomly show either heads or tails
????????????
-
Re: coins
"victor" <victor_cvy@hotmail.com> wrote:
>
>how to simulating a coins that turn and randomly show either heads or tails
>????????????
>
>This is something I did that simulates coin tossing:
int flip(void);
int main()
{
int frequency 0 = 0;
int frequency 1 = 0;
int face;
int counter;
srand(time(0));
for (counter = 1; counter <= 20; ++counter)
{
face = flip();
switch(face)
{
case 0:
++frequency0;
break;
case 1:
++frequency1;
break;
default:
cout << "Don't read this!";
}
}
cout << "Tails were rolled " << frequency0 << " times";
cout << "Heads were rolled " << frequency1 << " times";
return 0;
}
int flip(void)
{
int face;
face = rand() % 2;
return face;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks