標題:
C++語言去掉最高最低取平均程序
[打印本頁]
作者:
daming
時間:
2014-12-30 02:03
標題:
C++語言去掉最高最低取平均程序
本帖最后由 daming 于 2014-12-30 02:16 編輯
#include<iostream>
using namespace std;
void main()
{
int n,max,min,sum=0;
cout<<"請輸入十個評委的分數"<<endl;
cin>>n;
sum=max=min=n;
for(int i=0;i<9;i++){
cin>>n;
sum+=n;
if(n>max)
max=n;
else
min=n;
}
cout<<"選手的得分是"<<(sum-max-min)/8.0<<endl;
}
復制代碼
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1