#include <iostream>
#include <array>
int main() {
using namespace std;
cout<<"Enter 10 donation value(non-numeric to quit):"<<endl;
array<float,10> ar;
int i=0;
float sum=0;
float ave;
while(i<10&&cin>>ar[i])
{
sum+=ar[i];
++i;
}
if(i==0)
cout<<"Error! i can't be 0!"<<endl;
else
{
ave=sum/i;
int n_big=0;
for(int k=0;k<i;++k)
if(ar[k]>ave)
++n_big;
cout<<"The average of the numbers is: "<<ave<<endl;
cout<<n_big<<" number(s) is(are) bigger than average "<<ave<<endl;
}
return 0;
}
C++ primer plus 6th 6.2答案
最新推荐文章于 2024-11-10 13:26:37 发布