我被分配了一个需要 25 个双精度数组的程序。然后需要翻转和显示。我似乎无法让 flipArray 函数工作。
#include <iostream>
using namespace std;
const int NUMSCORES = 25;
//double getData(double &myArray);
void flipArray (int arr[]);
int main(void)
{
int scores[NUMSCORES], i;
for(i=0; i<NUMSCORES; i++){
cout << "Please enter scores #" << i+1 << ": ";
cin >> scores[i];
}
cout << "Your test scores:\n";
for(i=0; i<NUMSCORES; i++)
cout << "\tTest score #" << i+1 << ": " << scores[i] << endl;
flipArray(NUMSCORES);
return;
}
void flipArray(int arr[])
{
int j;
for (j=NUMSCORES-1; j>=0; j--)
cout << arr[j] << "\t";
}