#include
int main()
{
using namespace std;
int donation;
double average;
int sum;
int c,i;
for(i=1;i<=10;i++)
{
while(isdigit(donation))
cout<<"Enter "<
cin>>donation[i];
sum+=donation[i];
average=sum/i;
}
while(donation[i]>average)
c++;
cout<<"平均值="<<average;
cout<<"一共有"<<c<<"個數字大於平均值";
return 0;
}
[Error] D:\My Documents\C-Free\Temp\未命名1.cpp:14: error: invalid types int[int]' for array subscript
int[int]' for array subscript
[Error] D:\My Documents\C-Free\Temp\未命名1.cpp:17: error: invalid types
請問各位大大這個錯誤怎麼解決啊!!!好糾結!!!
#include<iostream>
int main()
{
using namespace std;
int donation[10];
double average;
int sum=0;
int c=0,i;
for(i=1;i<=10;i++)
{
while(isdigit(donation[i]))
cout<<"Enter "<<i<<" number:\n";
cin>>donation[i];
sum+=donation[i];
average=sum/i;
}
while(donation[i]>average)
c++;
cout<<"平均值="<<average;
cout<<"一共有"<<c<<"個數字大於平均值";
return 0;
}