首页 > 代码库 > 14周(多课程成绩表)
14周(多课程成绩表)
/*
*copyright(c) 2014,烟台大学计算机学院
*All rights reserved。
*文件名称:14周(多课程成绩表)
*作者:王忠
*完成日期:2014.12.01
*版本号:v1.0
*
*问题描述:输入同学各科成绩,自动求出总分,最高,最低,平均分.
*输入描述:各科成绩
*程序输出:总分,最高,最低,平均分.
#include <iostream> #include <string> using namespace std; void input(double s[][4],int n); void output(double s[][4],int n); double max(double s[][4],int n,int i); double min(double s[][4],int n,int i); double avg(double s[][4],int n,int i); int main() { int i,num; string temp; double score[100][4]; string course[4]= {"高等数学","英语","c++","总分"}; cout<<"输入学生人数:"; cin>>num; for(i=0; i<4; i++) { cout<<course[i]<<"\t"; } cout<<endl; input(score,num); output(score,num); for(i=0; i<3; ++i) { cout<<course[i]<<"的最高成绩是"<<max(score,num,i)<<","; cout<<"最低成绩是"<<min(score,num,i)<<","; cout<<"平均成绩为"<<avg(score,num,i)<<","; cout<<endl; } } void input(double score[][4],int num) { int sum=0,i,j; for (i=0; i<num; i++) { for(j=0; j<3; j++) { cin>>score[i][j]; sum=sum+score[i][j]; } score[i][j]=sum; sum=0; cout<<score[i][j]; cout<<endl; } } void output(double score[][4],int num) { int i,j; for (i=0; i<num; i++) { for(j=0; j<4; j++) cout<<score[i][j]<<"\t"; cout<<endl; } } double max(double score[][4],int n,int i) { int j=0,d; d=score[j][i]; for(; j<n; ++j) { if(d<score[j][i]) d=score[j][i]; } return d; } double min(double score[][4],int n,int i) { int j=0,x; x=score[j][i]; for(; j<n; ++j) { if(x>score[j][i]) x=score[j][i]; } return x; } double avg(double score[][4],int n,int i) { int j=0,sum; double average; for(; j<n; ++j) sum=sum+score[j][i]; average=sum/n; return average; }
14周(多课程成绩表)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。