它一直问我在 Double 之前的主要表达式,它在我的 int 数组中,我不知道该怎么做。我明天有期中考试啊,这伤害了我的大脑。所有其他输入都会有帮助谢谢:)
#include <iostream>
#include <iomanip>
using namespace std;
void get_input(double array[50], int& sizearray1)
{
cout << "How many doubles do you wish to add?" << endl;
cin >> sizearray1;
while(sizearray1 < 1 || sizearray1 > 50) {
cout << "Error: That is an invalid number! You must enter a value between 1 and 50.\nHow many doubles do you wish to add?" << endl;
cin >> sizearray1;
}
for(int n=1;n<sizearray1;n++){
cout << "Enter Double " << n << endl;
cin >> array[n];
}
}
double calcSum(double array[50],int sizearray1)
{
int sum
cout << "The sum is ";
for(n=1,n<sizearray1,n++){
sum += array[n]
}
cout << sum << endl;
}
void printArray(double c[],int sizearray1)
{
cout << "The array contains:\n";
for(int n=1;n<sizearray1;n++){
cout << setprecision(2) << showpoint << fixed << c[n] << " ";
}
calcSum(double array[50],int sizearray1);
}
int main()
{
double array1[50];
int sizearray1 = 0;
get_input(double array[50],int sizearray1);
printArray(double array[50],int sizearray1);