用函数调用的方法求字符串的最大值和最小值

#include <stdio.h>
#include "string.h"
float arry_maxandmin(a[10]){
    int temp,i = 0,j;
    for(j=0;j<10;j++){
        for (i = 0; i < 10- 1 - j; i++)
        {
            if(a[i] < a[i + 1])
            {
                temp = a[i];
                a[i] = a[i + 1];
                a[i + 1] = temp;
            }
        }
    }
   printf("The max is %d,The min is %d\n",a[0],a[9]);
    return 0;
}

int main(int argc, const char * argv[]) {

    int score[10];
    int i;
    printf("input 10 scores:\n");
    for(i=0; i<10; i++)
        scanf("%d",&score[i]);
        printf("\n");
    arry_maxandmin(score);//数组名作为函数参数




    return 0;
}

你可能感兴趣的:(函数)