#include <iostream>
#include <cmath>
using namespace std;
int main()
{
string num[21];
int amount_num;
cout<< "How many numbers do you want? (max 20)\n";
cin>> amount_num;
if (amount_num<= 0 || amount_num >= 22)
{
cout << "Invalid size. Ending.\n";
}
for (int counter =0; counter < amount_num; counter++)
{
cout<< "Enter vaule "<< counter<< ":"<< endl;
cin>> num[counter];
}
for(int t= 0; t< amount_num; t++)
{
int total;
int average;
total = total + num[t];
average= total/ t;
cout<< "Average: "<< average<< endl;
}
for(int x=0; x< amount_num; x++)
{
cout<< "You entered:"<< endl;
cout<< num[x]<< endl;
}
}
当我尝试将总数加 num[t] 相加时,不断弹出错误。它指出:error no operator+ in total+ num[t]。