[ create a new paste ] login | about

Link: http://codepad.org/lH742uKh    [ raw code | output | fork ]

C++, pasted on Apr 15:
#include <iostream>
#include <ctime>
#include <cmath>

using namespace std;

int main()
{

const int N=80;
double C[N], p = 1.0;
int i, k = 0;

srand(time(0));
for(i = 0; i < N; i++)
{
    C[i]= (double)(rand() % 50) / 10 ;
    if ( C[i] >= 1 && C[i] <= 2 )
    {
        p *= C[i];
        ++k;
    }
}
if ( k > 0 )
    cout << pow( p, 1.0/k );
else
    cout << k;
return 0;
}


Output:
1
1.46613


Create a new paste based on this one


Comments: