我得到了双元素和的奇怪错误,它看起来像1e + 002,当答案是双倍的时候。
const int ARRAY_SIZE =20;
//Index variable
int i;
//For finding average
double sum=0.00;
cout.precision(2);
srand((unsigned)time(0));
double main_array[ARRAY_SIZE];
//Header
cout << "Element number \t\t" << "Random Number\n\n" << endl;
//Assigning random values into array.
for (i=0; i< ARRAY_SIZE; i++)
{
//Randomizer
double ran =(rand()/((float)RAND_MAX/(10-0)));
main_array[i] = ran;
sum+=main_array[i];
答案 0 :(得分:2)