所以我有这个程序应该采用一个数组并按相反的顺序排列,并给出所述数字的平均值。输入负数时,程序终止。我非常接近完成它但目前我无法获得相反的方面。感谢帮助!
#include <iostream>
using namespace std;
int main(){
//Written By: Hannah Stang
//Reads a series of positive integers until user enters -1.
//Prints values in reverse order and gives the average of the values
cout << "Please enter positive integers as desired, when finished enter a negative integer to get results. ";
int sum = 0, avg, num, numsize = 0;
cin >> num;
void reverse (int array[] );
while (num >= 0)
{
numsize = numsize + 1;
sum = sum + num;
cin >> num;
avg = sum / numsize;
}
cout << "The values in reverse order are " << endl;
cout << "The average is " << avg << endl;
}