//I made only two changes description for the changes are given in the
// respective positions
#include <iostream.h>
#include <stdlib.h>
void main ()
{
unsigned int c,a,b;
static int total[14];
// static int is used to intialise the value of array "total" to 0
//Incresed length of the array because last element is total[13],
since max=13
int max=13;
randomize ();
for (int i=1;i<=10;i++)
{
a=rand() % 6 + 1;
b=rand() % 6 + 1;
c=a+b;
cout<<"Number rolled = "<<c<<endl;
++total[c];
}
for (int j=2;j<=12;j++)
{
total[max]=0;
total[max]=total[j];
//here value of c is constant only value of j is varying
cout<<j<<" "<<total[max]<<endl;
}
}
--- In [email protected], "darkshadow_x21"
<[EMAIL PROTECTED]> wrote:
>
> i didn't really understand the help i got from shyan since i am
> barely learning the c++ languange. all i need is to know how to
> count and total up thwe values for each number: for instance if a 6
> is rolled it will count 1 for 6 and show me the percentage of
> getting six after about 10 rolls or something. plz help
>
> #include <iostream.h>
> #include <stdlib.h>
> void main ()
> {
> randomize ();
> unsigned int c,a,b;
> unsigned int total[12];
> int max=13;
> for (int i=1;i<=10;i++)
> {
> a=rand() % 6 + 1;
> b=rand() % 6 + 1;
> c=a+b;
> cout<<"Number rolled = "<<c<<endl;
> ++total[c];
> }
> for (int j=2;j<=12;j++)
> {
> total[max]=0;
> total[max]=total[c];
> cout<<j<<" "<<total[max]<<endl;
> }
> }
>-----------------------------------------~-~>
CHECK THE ARCHIVE BEFORE POSTING!!!! Archive is available at
http://www.eScribe.com/software/C-Paradise/
>------------------------------------------_->
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/C-Paradise/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/