标签:c++ 生活
/*
*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; }
标签:c++ 生活
原文地址:http://blog.csdn.net/wangzhongwangmin/article/details/41646107