Enter the 6 student achievement, find the highest and lowest scores, using the function

/ *
================================================ ============================
the Name: max_min.c
Author: duanqibo
Version:
Copyright: Your Copyright Notice
the Description: enter the 6 student achievement , find the highest and lowest scores, with functions for
====================================== ======================================
* /

#include <stdio.h>
#include <stdlib.h>

int score_max(int s[],int n)
{
int i,m;
m=s[0];
for(i=1;i<n;i++)
{
if(s[i]>m)
m=s[i];
}
return m;
}

int score_min(int s[],int n)
{
int i,mi;
mi=s[0];
for(i=1;i<n;i++)
{
if(s[i]<mi)
mi=s[i];
}
return mi;
}

int main (void) {
int Score [. 6];
int I, max = 0, min = 0;
Setbuf (stdout, NULL);
the printf ( "Enter 6 students score:");
for (I = 0; I <. 6; I ++)
{
Scanf ( "% D", & score [I]); // inputs 6 student performance
}
max = score_max (score,. 6); // function call
min = score_min (score, 6) ; // call the function
printf ( "highest score:% d \ n lowest score:% D", max, min);
return. 1;
}

Guess you like

Origin www.cnblogs.com/duanqibo/p/11105133.html