输入十个学生的学号和五门课程的成绩 统计输出五门课总分最高和最低的学生的学号和总分

作者&投稿:寿尝 (若有异议请与网页底部的电邮联系)
用c语言, 输入10个学生的学号和5门课程的成绩,统计输出5门课总分最高和最低的学生的学号和他们的~

#includestruct Student{ char no[80] = {0}; double score[5] = {.0}; double tscore = .0; };int main(){ Student stu[10]; for(int i = 0;imax){ max = stu[i].tscore; maxno = i; } for(int i = 1;i<10;++i) if(stu[i].tscore<min){ min = stu[i].tscore; minno = i; } printf("%s
%lf
",stu[maxno].no,stu[maxno].tscore); printf("%s
%lf
",stu[minno].no,stu[minno].tscore); return 0; }

#include
#define N 3

/*输入10个学生的学号和三门课成绩,
*统计并输出总分最高的学号和总分。
**/

typedef struct{
char id[8];
int score1;
int score2;
int score3;
int sum;
}Student;

Student students[N];

Student input(){
Student student;
printf("学 号:");scanf("%s",&student.id);
printf("score1:");scanf("%d",&student.score1);
printf("score2:");scanf("%d",&student.score2);
printf("score3:");scanf("%d",&student.score3);
student.sum = student.score1+student.score2+student.score3;
return student;
}

int main(){
int i=0,maxScore=0,index=0;
for(i=0;i<N;i++){
printf("输入第%d个学生的信息:
",i+1);
students[i] = input();
if(students[i].sum>maxScore){
maxScore = students[i].sum;
index = i;
}
}
printf("
总分最高的是:%s
",students[index].id);
printf("他的总分是:%d",maxScore);

system("pause");
return 0;
}


"""
  100010 LI 78 89 98 65 53
  100011 Zhang 78 65 92 65 58   
  100012 Xie 89 76 63 99 100
  100013 Zkz 82 58 69 76 90
  100014 Wxj 76 88 62 100 96
  100015 Zcy 93 86 79 100 91
  100016 XieY 79 79 93 94 19
  100017 Zkzy 72 88 60 59 97
  100018 Wxjy 96 78 92 88 96
  100019 ZcyY 83 96 79 100 91

"""


class MaxMin:
    def __init__(self,dict1=None):
        self.dict1={}
         
    def Lin(self,s=0):
        str1=str(input('请按上面标注的格式输入:'))
        L1=str1.split()
        for i in L1[2:]:
            s=s+int(i)
            d=L1[0]
        self.dict1.update({d:s})
        print("学号{0},姓名{1},五门总分{2}".format(L1[0],L1[1],s))

    def maxx(self,max=0,max_k=0):
         self.max=max
         self.max_k=max_k
         for k,v in self.dict1.items():
              if self.max<self.dict1.get(k):
                 self.max=v
                 self.max_k=k             
    
    def minn(self,min=500,min_k=0):
         self.min=min
         self.min_k=min_k
         for k,v in self.dict1.items():   
              if self.min>self.dict1.get(k):
                 self.min=v
                 self.min_k=k
  
       
n=0
L=MaxMin()
while n<10:
     n+=1
     L.Lin()

for k,v in L.dict1.items():
   L.maxx()
   L.minn()
print('{0:*^30}'.format('统计结果'))
print('学号{0}的总分最高{1}分;学号{2}的总分最低{3}分'.format(L.max_k,L.max,L.min_k,L.min))


h


【高悬赏】写两道C语言程序: 1.输入10个学生的信息,输出最高分学生的...
float score;}Student;int main(){Student student[10],maxstu;float avrg=0.0;int i;printf("请输入10个学生的学号,姓名,成绩,用空格分割!\\n");for(i=0;i<10;i++)scanf("%d %s %f",&student[i].id,student[i].name,&student[i].score);maxstu=student[0];for(i=0;i<10;i...

(1)定义一个结构体数组,存放10个学生的学号,姓名,三门课的成绩; 急求...
、定义一个结构体数组,存放 10 个学生的学号,姓名,三门课的成绩 2、从键盘输入 10 个学生的以上内容,存入文件 stud.dat,关闭文件 3、打开 stud.dat 文件,将数据读出,查看是否正确写入,关闭文件。 4、打开文件 stud.dat 文件,读出数据,将 10 个学生按照平均分数从高到低进 行排序,分别将结果输出到屏幕上和...

输入一个班10个学生的学号和每个学生考试三门功课(数学、英语、计算机...
我的已经算出他们的平均数了,你看行不行啊~struct students { char num[7];char name[20];int scores[3];float ave;float max;};main(){ struct students stu[4];int m,n,i=0;float sum,max=0;for(m=0;m<4;m++){ printf("input the No:%d student's:\\n",m+1);printf("...

用c语言的数组解。 4、输入10个学生的信息,每个学生含有成员名为“学号...
include<stdio.h> struct student { char no[15];char name[15];int yuwen,shuxue,yingyu,total;}a[10];void main(){ int i;for(i=0;i<10;i++){ printf("请输入学号\\n");scanf("%s",&a[i].no);printf("请输入姓名\\n");scanf("%s",&a[i].name);printf("请输入语文成绩\\n...

...的数据包括:学号、姓名成绩,从键盘输入10个学生的数据,输出成绩最高...
caverage(); \/*求各学生语文平均分、最高和最低分成绩的函数*\/ break; case 9: maverage(); \/*求各学生数学平均分、最高和最低分成绩的函数*\/ break; case 10: eaverage(); \/*求各学生英语平均分、最高和最低分成绩的函数*\/ break; case 11: comaverage(); \/*求各学生计算机平均分、最高和最...

(1)定义一个结构体数组,存放10个学生的学号,姓名,三门课的成绩; (2...
include <stdio.h> include <string.h> typedef struct STU { char ID[20];\/\/学号 char Name[20];\/\/姓名 float math;\/\/成绩1 float chinese;\/\/成绩2 float english;\/\/成绩3 };int main(){ STU myStu[10];for(int i = 0; i < 10;i++){ printf("请输入第%d个学生的信息\\n",i...

java题 从键盘输入10个学生的信息(姓名,学号,电话) 然后打印出来_百度...
public class InputMessage { \/ 主函数 param args \/ public static void main(String[] args) { InputMessage im = new InputMessage();Scanner sc = new Scanner(System.in);int j=1;String[] s = new String[12];System.out.print("请输入第1个学生的信息(姓名、学号、电话):");whil...

有10个学生,每个学生的数据包括学号、姓名、三门课的成绩,从键盘输入10...
include "stdio.h"include <stdlib.h> define SIZE 10 struct student{ char id[20];char name[20];int score[3];int total;} stud[SIZE];void main(){ int i,j;struct student temp;for(i=0;i<SIZE;i++){ printf("第%d个学生的信息:\\n",i+1);scanf("%s%s%d%d%d",...

用C语言编程:从键盘输入10个学生的成绩,由高到低排序输出成绩
你好,我们这里需要用到数组镶套使用for函数以及冒泡算法,具体的代码如下。include <iostream> using namespace std;int main(){ int s [10], i, j, t;cout << "输入10个数:";for (i = 0; i < 10; i++){ cout << "请输入第" << i+1 << "名学生的成绩;" << endl;cin >...

C语言编程,从键盘输入10个学生的成绩,试统计出他们的成绩总和及平均值...
printf("请输入学生的学号 姓名 语文 数学 英语");input(MAX);average(MAX);printf("\\n课程的平均成绩是: %6.2f %6.2f %6.2f\\n",ave_course[0],ave_course[1],ave_course[2]);printf("\\n学生的平均成绩是: \\n");for(i=0; i<MAX; i++) { printf(" %s %s %6.2f\\n", ...

伊宁县19489848435: 输入10个学生5门课的成绩,分别用数组实现下列功能:输入10个学生5门课的成绩,分别用数组实现下列功能:(1)计算每个学生的平均分;(2)计算每... -
太翔帕诺:[答案] 用C语言实现的话,不难,这里写一下伪代码: 假设输入的分数为整数int,既然有计算平均分,就可能有小数,平均分定义成float 数据用二维数据表示a[1][1,2,3,4,5] 用循环输入: for(i=1;iscanf语法输入 } 计算(1)a[1][1]+a[1][2]+a[1][3]+a[1][4]+a[1][5...

伊宁县19489848435: C语言编程1、编写一个程序实现如下功能:输入10个学生5门课程的成绩,分别用函数求:①每个学生的平均分;②每门课程的平均分;③找出最高的分数所... -
太翔帕诺:[答案] 第一题:#include #include #define STUDENT_NUM 2 //学生数量,修改成10即可#define COURSE_NUM 5 //课程数量,为5typedef struct { float course[COURSE_NUM]; float ave;} student;void main(){ student s...

伊宁县19489848435: C语言 输入10个学生5门课的成绩,分别写3个函数完成: -
太翔帕诺: #include void pjun(int a[][5]) { int pjun[10]; int i,j,sum; for(i=0;i { sum=0; for(j=0;j sum+=a[i][j]; pjun[i]=sum/5; printf("%6d",pjun[i]); } } void pjun2(int a[][5]) { int i,j; int sum,pjun[5]; for(j=0;j { sum=0; for(i=0;i sum+=a[i][j]; pjun[j]=sum/10; printf("%6d",pjun[...

伊宁县19489848435: 输入10个学生的学号和5门课的成绩,并统计5门课的总分最高和总分最低的学生的学号和他们的总分 -
太翔帕诺: #include<stdio.h> #define H 10 #define pr printf #define s scanf main() {int i,n[6],m,x,max,min; pr("请输入%d个学生的信息\n\n",H); for(i=1;i<H+1;i++) { pr("\n\n第%d个学生的信息:\n\n 学 号:",i); s("%d",&n[0]); pr(" 成绩1:"); ...

伊宁县19489848435: 输入10个学生5门功课的成绩,分别用函数求:①每个学生的平均分;②每门课平均分;③找出最高的分数所对…输入10个学生5门功课的成绩,分别用函数... -
太翔帕诺:[答案] 留下邮箱,我把源代码发给你 //prog_fun.c写入 #include #include #define N 10 #define M 5 float *average(float a[][M])//每个学生平均分 { int i,j; float ave,*stu=new float; printf("各个学生平均分为:\n"); for(i=0;i{for(ave=0,j=0;jave+=a[i][j]; stu[i]=ave/M;...

伊宁县19489848435: 输入十个学生的学号和五门课程的成绩 统计输出五门课总分最高和最低的学生的学号和总分 -
太翔帕诺: """ 100010 LI 78 89 98 65 53 100011 Zhang 78 65 92 65 58100012 Xie 89 76 63 99 100 100013 Zkz 82 58 69 76 90 100014 Wxj 76 88 62 100 96 100015 Zcy 93 86 79 100 91 100016 XieY 79 79 93 94 19 100017 Zkzy 72 88 60 59 97 ...

伊宁县19489848435: c语言,输入十个学生五门课的成绩,分别用函数求(1)每个学生的平均成绩(2)最高分所对应的学生和课程 -
太翔帕诺: 学号和成绩可以通过文件输入或键盘输入,这里假定已通过初始化给入了. av()计算平均分. best() 返回成绩最好的学生的 结构数组元素的下标.#include struct st { int num; float score[5]; float mean; } ;void av(struct st *s, int n)...

伊宁县19489848435: C语言题 :分别用函数和数组实现,输入10个学生5门课的成绩 -
太翔帕诺: 仅供参考 #include <stdio.h> #define S 10 #define C 5 int scores[S][C]; void input(void) {int i, j;for(i = 0; i < S; i ++){printf("input %d scores of student %d \n", C, i+1);for(j = 0; j < C; j ++)scanf("%d", &scores[i][j]);} }void calc_ave(void) {...

伊宁县19489848435: c++编写程序有十个学生,每个学生的数据包括学号 姓名 5门功课的成绩.从键盘输入10名学生的成绩 -
太翔帕诺: #include <iostream> using namespace std;// 声明一个结构体保存学生的信息 struct Student { int id; char name[11]; //这里限制了name的长度 int score[5]; //这里声明了一个长度为5的int数组 };// 声明并定义函数计算学生5门成绩的总和 int sum...

伊宁县19489848435: 用c语言:输入10个学生5门课的成绩,分别用函数求:(1)每个学生平均分;(2)每门课的平均数分; -
太翔帕诺: #include<stdio.h> void main() { int i,j,score[2][3]={{1,2,3}{2,3.4}},v[2],sum=0,average,max; max=a[0][0]; for(i=0;i<2;i++) { for(j=0;j<3;j++) { if(a[i][j]>max) {max=a[i][j];} sum=sum+a[i][j]; } v[i]=sum/i;//每个同学的平均分; sum=0;//把总分值清零; } ...

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 星空见康网