第13周上机实践项目3――成绩处理函数版

2015-01-27 06:10:13 · 作者: · 浏览: 11

问题及代码

/*
 * Copyright (c) 2014, 烟台大学计算机学院
 * All rights reserved.
 * 文件名称:test.cpp
 * 作    者:辛彬
 * 完成日期:2014年 11 月 25 日
 * 版 本 号:v1.0
 *
 * 问题描述: 输出考得最高成绩和最低成绩的同学的人数。

 * 输入描述:人数及成绩。
 * 程序输出:最高成绩和最低成绩的同学的人数;
 */
#include 
  
   
using namespace std;
void input_score(int s[], int n); //将小组中n名同学的成绩输入数组s
int get_max_score(int s[], int n);  //返回数组s中n名同学的最高成绩值
int get_min_score(int s[], int n);  //返回数组s中n名同学的最低成绩值
double get_avg_score(int s[], int n);  //返回数组s中n名同学的平均成绩值
int count(int x, int s[], int n);  //返回在数组s中n名同学中有多少人得x分(实参给出最高/低时,可以求最高/低成绩的人数)
void output_index(int x, int s[], int n); //在函数中输出数组s中n名同学中得x分的学号(下标)
int main(void)
{
    int score[50]; //将score设为局部变量,通过数组名作函数参数,传递数组首地址,在函数中操作数组
    int num;       //小组人数也设为局部变量,将作为函数的实际参数
    int max_score,min_score;
    cout<<"小组共有多少名同学?";
    cin>>num;
    cout<
   
    >s[i]; } while(s[i]<0||s[i]>100); } } int get_max_score(int s[], int n) { int high=s[0]; for(int i=0; i
    
     high) high=s[i+1]; } return high; } int get_min_score(int s[], int n) { int low=s[0]; for(int i=0; i
     
      
运行结果:

学习感悟:重要的是定义名,千万要统一。。。。。。