題目描述
輸入10個整數,求它們的平均值,并輸出大于平均值的數據的個數。
輸入
10個數
輸出
大于平均數的個數
樣例輸入
1 2 3 4 5 6 7 8 9 10
樣例輸出
5
參考代碼
#include<iostream>
using namespace std;
int main()
{
int n,c,a[10];
n=0;
c=0;
double b;
for(int i=0;i<10;i++)
{
cin>>a[i];
n+=a[i];
}
b=n/10;
for(int j=0;j<10;j++){
if(a[j]>b)
c+=1;
}
cout<<c<<endl;
return 0;
}
運行結果
- 若有問題,請評論出來!