{
// FIRST ARRAY
int NumberOfXValues;
double* FirstArray;
NumberOfXValues = 0;
FirstArray = new double[NumberOfXValues];
// END FIRST ARRAY
// SECOND ARRAY
int NumberOfProbabilities;
double* SecondArray;
NumberOfProbabilities = 0;
SecondArray = new double[NumberOfProbabilities];
// END SECOND ARRAY
// THIRD ARRAY
int Product;
double* ThirdArray;
Product = 0;
ThirdArray = new double[Product];
// END THIRD ARRAY
// OBTAINING THE NUMBER OF X VALUES
cout << "Please input the number of \"x\" values we will be using: ";
cin >> NumberOfXValues;
// END OF OBTAINING THE NUMBER OF X VALUES
// OBTAINING THE VALUES IN THE FIRST ARRAY
int x;
cout << "Please input the \"x\" values in order from least to greatest: " << endl;
cout << endl;
for (int x = 0; x < NumberOfXValues; x++)
{
cout << "Enter number: ";
cin >> FirstArray[x];
}
cout << endl;
// END OF OBTAINING THE VALUES IN THE FIRST ARRAY
// OBTAINING THE VALUES IN THE SECOND ARRAY
cout << "Please input the probabilities corresponding to their \"x\" values: " << endl;
cout << endl;
for (int x = 0; x < NumberOfXValues; x++)
{
cout << "Enter probability in decimal form: ";
cin >> SecondArray[x];
}
cout << endl;
// END OF OBTAINING THE VALUES IN THE SECOND ARRAY
// MULTIPLYING THE FIRST TWO ARRAYS TO OBTAIN THE THIRD
for (int x = 0; x < NumberOfXValues; x++)
{
ThirdArray[x] = FirstArray[x] * SecondArray[x];
}
// END OF MULTIPLYING THE FIRST TWO ARRAYS TO OBTAIN THE THIRD
//TEST
for (int x = 0; x < NumberOfXValues; x++)
{
cout << ThirdArray[x];
cout << endl;
}
//TEST
}
这是我第一次使用这些网站,但我已经工作了将近一个多小时来解决这个问题。它运行完全平稳,直到它显示第三个数组中的第三个值。它总是给我一个奇怪的数字。