c语言输入10个评委给6个选手打分去掉一个最高分和最低分,然后求平均分,输出前3位评委
#include "stdio.h"
#include "string.h"
#include "stdlib.h"
struct student
{char num[10];
char name[10];
char sex[5];
char age[2];
int remark;
struct student *prior;
struct student *next;
}l;
struct student *start,*last;
void enter(),list(),save(),
load(),delete_();
void store(struct student *g);
meun(),score();
main()
{
char s[6],a[6];
start=last=NULL;
load();
for(;;){
switch(meun()){
case 1:enter();
break;
case 2:list();
break;
case 3:save();
break;
case 4:delete_();
break;
case 5:score();
break;
case 6:exit(0);}
}
}
meun()
{char s[10];
int c;
printf("选手信息管理系统
");
printf("------------------------------------------
");
printf("[1.选手基本信息录入] [2.选手基本信息显示]
");
printf("------------------------------------------
");
printf("[3.选手基本信息保存] [4.选手基本信息删除]
");
printf("------------------------------------------
");
printf("[5.评委为选手打分 ] [6.退出管理系统 ]
");
printf("------------------------------------------
");
printf("请按数字选择");
gets(s);
c=atoi(s);
if(c=1)
return(c);
}
void enter()
{
struct student *info;
info=(struct student *)malloc(sizeof(struct student));
if(!info){
printf("EMS run out of!
");
return;}
for(;;){
info=(struct student *)malloc(sizeof(struct student));
if(!info){
printf("EMS run out of!
");
return;}
printf("输入姓名:");gets(info->name);
printf("
");
if(!*info->name) break;
printf("输入号码:");gets(info->num);
printf("
");
printf("输入性别:");gets(info->sex);
printf("
");
printf("输入年龄:");gets(info->age);
printf("
");
info->remark=0;
store(info);
}
}
void store(struct student *g)
{
if(last==NULL){
g->next=NULL;
g->prior=NULL;
last=g;
start=g;
return;
}
g->next=NULL;
g->prior=last;
last->next=g;
last=g;
}
void display(struct student *info)
{
printf("姓名:%s
",info->name);
printf("号码:%s
",info->num);
printf("性别:%s
",info->sex);
printf("年龄:%s
",info->age);
printf("分数:%d
",info->remark);
return;
}
void list()
{
struct student *info;
info=start;
while(info){
display(info);
info=info->next;
}
}
struct student *find(struct student *p)
{int a,b;
struct student *info;
info=start;
if(!info){
printf("File not load!
");
return(NULL);
}
while(info){
if(!strcmp(p->name,info->name)){
return(info);}
info=info->next;
}
printf("无此记录
");
return(NULL);
}
void delete_()
{
struct student *info;
printf("输入需要删除记录的姓名:");
info=(struct student *)malloc(sizeof(struct student));
gets(info->name);
info=find(info);
if(!info) return;
if(!(info==start)&&!(info==last)){
info->next->prior=info->prior;
info->prior->next=info->next;
}
else{if((info->prior==NULL)&&(info->next==NULL))
last=start=NULL;
else{
if(info==last){
info->prior->next=NULL;
last=info->prior;
}
else{
info->next->prior=NULL;
start=info->next;
}}
}
free(info);
return;
}
void save()
{struct student *info;
FILE *fp;
if((fp=fopen("f:\\student.kbm","wb"))==NULL){
printf("error
");
return;
}
info=start;
printf("saving!
");
while(info){
fwrite(info,sizeof(struct student),1,fp);
info=info->next;
}
fclose(fp);
}
void load()
{
struct student *info;
FILE *fp;
if((fp=fopen("f:\\student.kbm","rb"))==NULL){
printf("error
");
return;
}
info=(struct student *)malloc(sizeof(struct student));
if(!info){
printf("EMS run out of!
");
return;
}
printf("loading!
");
info->prior=NULL;
info->next=NULL;
start=last=info;
while(!feof(fp)){
if(1!=fread(info,sizeof(struct student),1,fp)) break;
info->next=(struct student *)malloc(sizeof(struct student));
if(!info->next){
printf("EMS run out of!
");
return;
}
last=info;
info=info->next;
}
free(info);
last->next=NULL;
fclose(fp);
}
int sum()
{
int a[5],sum=0,i,max,min;
for(i=0;i<=4;i++){
printf("输入第%d个评委的打分",i+1);
scanf("%d",&a[i]);
getchar();
sum=a[i]+sum;
}
max=min=a[0];
for(i=1;i<=4;i++)
{
if(max<a[i])
max=a[i];
if(min>a[i])
min=a[i];
}
sum=(sum-max-min)/3;
return(sum);
}
score()
{ struct student *info;
printf("输入需要打分选手的姓名:");
info=(struct student *)malloc(sizeof(struct student));
gets(info->name);
info=find(info);
info->remark=sum();
return;
}
#includeintmain(){intx,yx=0,tg=0,bjg=0;scanf("%d",&x);while(x>0){if(x>85)yx++;elseif(x>=60)jg++;elsebjg++;scanf("%d",&x);}printf("优秀%d人
",yx);printf("通过%d人
",jg);printf("不及格%d人
",bjg);return0;}
#include<stdio.h>
int main ()
{
double a[10], max, min, sum, ava;
int i;
for (i = 0; i < 10; i++)
scanf ("%lf", &a[i]);
//--------^-------
max = a[0];
min = a[0];
sum = 0;
for (i = 1; i < 10; i++)
{
if (a[i] > max)
max = a[i];
}
for (i = 1; i < 10; i++)
{
if (a[i] < min)
min = a[i];
}
for (i = 0; i < 10; i++)
sum = sum + a[i];
ava = (sum - max - min) / 8;
printf ("%.1lf
", ava);
//--------^-------
return 0;
}
我这个是C++的代码 里面含有标准库。
#include<iostream>
#include<vector>
#include<deque>
#include<string>
#include<algorithm>
#include<ctime>
using namespace std;
class Person
{
public:
Person(){};
Person(string name, double score)
{
this->m_Name = name;
this->m_Score = score;
}
string m_Name;
double m_Score; //平均分
};
void creatPerson(vector<Person>&v,int n)
{
int score = 0;
for (int i = 0; i < n; ++i)
{
string name1 = to_string(i+1); //int类型转化为string类型
string name2 = "号选手";
name1 += name2;
Person p(name1, score);
v.push_back(p);
}
}
void printVector(vector<Person>&v)
{
for (vector<Person>::iterator it = v.begin(); it != v.end(); ++it)
{
cout << it->m_Name << "最终平均分数为:" << it->m_Score << endl;
}
}
void printVector2(vector<Person>&v)
{
for (vector<Person>::iterator it = v.begin(); it != v.end(); ++it)
{
cout << it->m_Name << " ";
}
cout << endl;
}
void setVector(vector<Person>&v,int m)
{
for (vector<Person>::iterator it = v.begin(); it != v.end(); ++it)
{
deque<int>d;
cout << "已为" << it->m_Name <<"打了"<<m <<"次分:" << endl;
for (int i = 0; i < m; ++i)
{
int score = rand() % 41 + 60; // 打分区间60~100
d.push_back(score);
}
for (deque<int>::iterator dit = d.begin(); dit != d.end(); ++dit)
{
cout << *dit << " ";
}
cout << endl;
sort(d.begin(), d.end());
d.pop_front();
d.pop_back();
/*for (deque<int>::iterator dit = d.begin(); dit != d.end(); ++dit)
{
cout << *dit << " ";
}
cout << endl;*/
int sum = 0;
for (deque<int>::iterator dit = d.begin(); dit != d.end(); ++dit)
{
sum += *dit;
}
//cout << "sum=" << sum << "数量" << d.size() << endl;
double avg = sum*1.0 / d.size();
it->m_Score = avg;
}
cout << endl;
}
void sortScore(vector<Person>&v)
{
vector<Person>::iterator it = v.begin();
Person t;
for (unsigned int i = 0; i < v.size(); ++i)
{
for (unsigned int j = 0; j < v.size() - i - 1; ++j)
{
if (it[j].m_Score>it[j + 1].m_Score) //比较分数
{
t = it[j]; //更换整体
it[j] = it[j + 1];
it[j + 1] = t;
}
}
}
}
int main(void)
{
cout << "软件说明:" << endl;
cout << "该软件为N个评委为M个选手打分,这样每一个选手就收到N次打分,去掉一个最低分和一个最高分,算出选手的平均分,并为这些选手按平均分从低到高排序。" << endl;
cout << endl;
cout << "请输入选手的个数N=";
int n;
while (true)
{
char c = cin.peek();
if (c > '0'&& c <= '9')
{
cin >> n;
cout << "你设置的选手人数为:" << n << endl;
break;
}
cin.clear(); //重置标志位
cin.sync(); //清空缓冲区
cout << "你输入不正确,请重新输入" << endl;
}
getchar();
cout << endl;
cout << "请输入评委的个数M=";
int m;
while (true)
{
char c = cin.peek();
if (c > '0'&& c <= '9')
{
cin >> m;
cout << "你设置的评委人数为:" << m << endl;
break;
}
cin.clear(); //重置标志位
cin.sync(); //清空缓冲区
cout << "你输入不正确,请重新输入" << endl;
}
cout << endl;
cout << "请这"<<m<<"个评委为选手打分:"<<endl;
cout << "(为了避免手动输入分数浪费时间,下面让计算机随机为选手打"<<m<<"次分。)" << endl;
cout << endl;
srand((unsigned int)time(NULL)); //随机数种子
vector<Person>v;
creatPerson(v,n);
//printVector(v);
setVector(v,m);
cout << endl;
cout << "去掉一个最低分,去掉一个最高分:"<<endl;
printVector(v);
cout << endl;
cout << "选手成绩由低到高排序如下:" << endl;
sortScore(v);
printVector2(v);
system("pause");
return 0;
}
C语言。在歌手大赛中,有10个评委为参赛选手打分
void main(){ int i;float a[10], min, max, sum;printf("请输入10个评委所给分数(空格隔开):");scanf("%f%f%f", &a[0],&a[1],&a[2],&a[3],&a[4],&a[5],&a[6],&a[7],&a[8],&a[9]);min = max = a[0];sum = a[0];for(i=1; i<10; i++){ sum +...
用C语言编程:歌手大奖赛有10名评委打分,去掉一个最高分、去掉一个最低...
float a[10],min,max,s=0;\/\/定义一个数组用来存放10个评委的分数。定义的min,max,是用来超查找最高分和最低分的。int i;printf("请输入10个评委的分数:\\n");for(i=0;i<10;i++)scanf("%f",&a[i]);min=s_min(a);max=s_max(a);\/\/调用函数找出低分和最高分。printf("去掉一...
c语言程序设计 评委打分
int main(void){ int i, j ;int s[10];int temp;int alls=0;for(i=0;i<10;i++){\/\/输入分数 printf("\\n请输入第%d名评委的打分:",i+1);scanf("%d",s+i);} for(i=0;i<10;i++){\/\/排序 for(j=0;j<10-i;j++){ if(s[j]<s[j+1]){ temp=s[j];s[j]=s[j+...
c语言输入10个评委给6个选手打分去掉一个最高分和最低分,然后求平均分...
include<stdio.h>int main (){ double a[10], max, min, sum, ava; int i; for (i = 0; i < 10; i++) scanf ("%lf", &a[i]); \/\/---^--- max = a[0]; min = a[0]; sum = 0; for (i = 1; i < 10; i++) { if (a[i] > max)...
用C语言编程,输入10个评委得分,去掉一个最高分和最低分,输出最终评委得 ...
) {t=a[j];a[j]=a[j+1];a[j+1]=t;} \/*排序*\/ for(i=0;i<10;i++) printf("%d ",a[i]); \/*去掉一个最高分和最低分*\/ for(i=1;i<9;i++) sum+=a[i];avg=(float)sum\/8; \/*求平均分*\/ printf("平均分是 %f ",avg);} ...
C语言:歌星大奖赛中,有十个评委为参赛的选手打分,分数为1-100分,选...
cout<<"最公平评委是第"<<g<<"位评委。"<<endl;cout<<"最不公平评委是第"<<h<<"位评委。"<<endl;return 0;} C语言代码技巧 1、使用合适的条件语句 除代码的可读性之外,程序的执行时间还主要依赖于做决定时所选择的条件结构类型。许多硬件工程师都熟悉简单的if语句的使用。然而,有时工程师...
c语言教程青年歌手参加大赛又十个评委打分,试求选手有效分数和平均分...
include<stdio.h>void main(){int i;float a[10], min, max, sum;printf("请输入10个评委所给分数(空格隔开):");scanf("%f%f%f", &a[0],&a[1],&a[2],&a[3],&a[4],&a[5],&a[6],&a[7],&a[8],&a[9]);min = max = a[0];sum = a[0];for(i=1; i<10; ...
编程题:为比赛选手评分,读入10名评委的评分,从中扣除一个最高分和一个...
编程题:为比赛选手评分,读入10名评委的评分,从中扣除一个最高分和一个最低分,输出这个选手的最后得分 #include<stdio.h>voidmain(){inta[10],i,max,min,sum=0;printf("输入10名评委的评分:\\n");for(i=0;i<10;i++)scanf("%d",&a[10]);max=a[0];min=a[0];for(i=0;i<10;i++){if(max...
用C语言编程:有10个评委对进行打分,试编程求平均得分(去掉一个最高分...
void main(){ float score[10];float min,max,ave;float sum=0.0;int i;printf("input 10 score:\\n");for(i=0;i<10;i++) scanf("%f",&score[i]);printf("\\n");min=score[0];max=score[0];for(i=0;i<10;i++){ sum=sum+score[i];if(score[i]>max) max=score[i];...
C语言编程题:歌唱比赛十个评委打分,请求出其中的最高分和最低分并进行...
include<stdio.h>int main(void){ float a[10],temp; printf("请输入分数:\\n"); int i,j; for(i=0;i<10;i++) { scanf("%f",&a[i]); } for(i=0;i<9;i++) { for(j=0;j<9-i;j++) { if(a[j]...
蹉向消痛: main() {float num[10]; float max.min; int i,aver,sum1,sum2,sum; 以上三行是定义变量 printf("请依次输入评委评的分数\n"); for(i=0;i{printf("第i+1位:"); scanf("%f",&x[i]);} 把十个分数定义为一维数组,用循环语句,输入十个分数 ...
富源县18952572911: 用C语言编程,输入10个评委得分,去掉一个最高分和最低分,输出最终评委得分. - ?
蹉向消痛: #include "stdio.h" void main() {int i,a[9],zongfen=0; float pingjunfen; for(i=0;i<9;i++) { printf("输入第个%d评委给的成绩:",i+1); scanf("%d",&a[i]); } int max=a[0],min=a[0]; for(i=1;i<9;i++) if(a[i]>max) max=a[i]; for(i=1;i<9;i++) if(a[i]<min) ...
富源县18952572911: c语音编程 10个评委给选手打分,最后去掉最高分,其余9个得分的平均值 - ?
蹉向消痛: main() { int max,i,a[10]; float j; for (i=0;i<10;i++) {scanf("%d",&a[i]); if (i==0) max=a[0]; if (a[i]>max) max=a[i]; j+=a[i];} j=(j-max)/9; printf("%f\n",j); }
富源县18952572911: c语言程序设计:输入评委选手信息,使用链表,评委为选手打分,去掉最高分和最低分, - ?
蹉向消痛: 我给你一个,我调试过的include <stdio.h> #include <string.h> #include <malloc.h> #define NULL 0 struct stu {int num;int age;struct stu *next; }; struct stu * creat(int n) {struct stu * head,*pb,*pf;int i;for(i=0;i<n;i++){pb=(struct stu *)malloc(...
富源县18952572911: c语言编程~~~纠结 - ?
蹉向消痛: #include<stdio.h>#include<stdlib.h> int main() { int mark[10][7], max[10]={0,0,0,0,0,0,0,0,0,0}, min[10]={10,10,10,10,10,10,10,10,10,10}; float f[10]; int i,k; printf("Please input singer's score: "); for(i=0;i<10;i++) for(mark[i][6]=0,k=0;k<6;k++) { scanf(...
富源县18952572911: C语言 12位评委采用百分制计分,规则是去掉一个最高分,去掉一个最低分,再取平均分.编程,输入各评 - ?
蹉向消痛: #include<stdio.h> void main() {int i,j;float a[12],avg,t,s=0;printf("请输入12个分数");for(i=0;i<12;i++)scanf("%f",&a[i]);for(i=0;i<12;i++){for(j=0;j<12-i;j++)if(a[j]>a[j+1]){t=a[j];a[j]=a[j+1];a[j+1]=t;}}for(i=0;i<12;i++){a[0]=0;a[11]...
富源县18952572911: C语言程序设计1)在青年歌手大奖赛中,有10个评委为参赛的5选手打分,分数为1~100分.选手最后得分为:去掉一个最高分和一个最低分后其余8个分数... - ?
蹉向消痛:[答案] #include
富源县18952572911: C语言编程题目,关于十个评委给选手打分的问题,去掉一个最高分和最低分,然后求平均分 - ?
蹉向消痛: #include#define N 10 void input(int score[],int length); void ovwrscore(int score[],int length); void input(int score[],int length) {int i; for(i=0;j { prihtf(“输人分数%d=",i+1); scanf("%d ,&score[i]); int averScore(int score[], int length) { int i, max, min,sum; ...
富源县18952572911: 在一次评奖中有十个评委对五个参赛选手打分,选手的最终得分为,去掉 - ?
蹉向消痛: 先求中间三个裁判共打分:3*9.56=28.68 如果只去掉一个最低分,平均得分9.64分, 则最高分为:4*9.64-28.68=38.48-28.68=9.8 如果只去掉一个最高分,那么平均得分945分. 则最低分为:4*9.45-28.68=37.8-28.68=9.12 所以如果保留最高分和最低分,而去掉其他评委的打分,小强的平均分是(9.8+9.12)÷2=9.46
富源县18952572911: C语言评分程序 - ?
蹉向消痛: #include #include #define MAX_LENGTH 6struct Student {char name[10];unsigned int ordernum;double scores[5]; };void printInfo(Student students[]) {for (unsigned int i=0;i {printf("学生姓名:%s\n",students[i].name);printf("学生出场...