歌星大赛
来源:互联网 发布:超人软件站官网 编辑:程序博客网 时间:2024/04/30 04:51
//在歌星大奖赛中,有10个评委为参赛的选手打分,分数为1~100分。
//选手最后得分为:去掉一个最高分和一个最低分后其余8个分数的平均值。请编写一个程序实现。
//基本思路:10个元素的数组,找到最大值和最小值并置为0,然后求和 求平均值
//*加上的思考
//题目条件不变,但考虑同时对评委评分进行裁判,即在10个评委中找出最公平(即评分最接返平均分)和最不公平(即与平均分的差距最大)的评委,
//程序应该怎样实现?
//既是求每个元素值跟平均值差值最大与最小的,可以再加一个数组来存放差值数据,然后求出最大值和最小值
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
float a[10],sum=0.0,average;
int i=0;
int j=0;
float max,min;
float max1,min1;
float b[10];
int m=0,n=0;//记录下最大最小的坐标,初始化
cout<<"input the scores of eash judge:"<<endl;
while(i<10)
{
cout<<"the "<<i+1<<"th judge's socre is:"<<endl;
cin>>a[i];
if(a[i]>100 || a[i]<1)//limit the score
cout<<"the score is error ,please input again!"<<endl;
else i++;
}
//to find the max and min
max=a[0];
min=a[0];
for(i=0;i<10;i++)
{
if(a[i]>max)max=a[i];
if(a[i]<min)min=a[i];
}
for(i=0;i<10;i++)
if(a[i]!=max && a[i]!=min )//drop the max and the min
sum+=a[i];
average=sum/8;
cout<<"the results score which drop the max and the min of this singer is:"<<average<<endl;
i=0;j=0;
while(i<10 && j<10 )
{
b[j]=fabs(a[i]-average);
j++;
i++;
}
max1=b[0];
min1=b[0];
for(j=0;j<10;j++)
{
if(b[j]>max1)
{max1=b[j];
m=j;}
if(b[j]<min1)
{
min1=b[j];
n=j;
}
}
cout<<"the longthen of average is: "<<max1
<<"it's the "<<m+1<<"th value "
<<"and the score is: "<<a[m]<<endl;
cout<<"the shorthen of average is: "<< min1
<<"it's the "<<n+1<<"th value "
<<"and the score is : "<<a[n]<<endl;
return 0;}
从中学习到:数组的元素可以随机访问,变量使用前最好初始化
0 0
- 歌星大赛
- 歌星大奖赛
- 歌星大奖赛
- 歌星大奖赛
- 歌星大奖赛
- 歌星大奖赛
- 歌星大奖赛
- 让我们荡起双浆-小歌星
- 歌星大奖赛,评分系统
- 4歌星大奖赛
- 大赛
- 娱乐圈里还有多少歌星在假唱?
- (百例编程)4.歌星大奖赛
- 歌星得分并且得出最好/差裁判!
- 【春晚歌星】著名歌唱家拉齐献声人气民族好歌
- 最简单的问题与算法(歌星大奖赛)
- 电子设计大赛
- 编程大赛
- 让Git以彩色输出
- 3D游戏技术 - 大型3D地图优化渲染技术
- Linux下的压缩解压缩命令详解
- Oracle锁-OWI体系中的认识
- 总线-设备-驱动模型
- 歌星大赛
- 项目总结
- 系统吞吐量(TPS)、用户并发量、性能测试概念和公式
- ntp 服务的搭建
- cocos2d-x 博客整理
- ActiveX开发实用文章列表
- 分治法求解放苹果问题(量子力学的状态问题,完全相同的苹果和完全相同的盘子)
- C++字符串流保存数据
- 【python】Resource temporarily unavailable