float score_Math[M];
printf("请输入所有%d个学生的数学成绩:\n",M); input_Scroes(score_Math); printf(“所有学生的数学成绩如下: \n”); output_Scroes(score_ Math); }
03 班级成绩的最高分问题求解 数组名是地址常量 score_Math
…
score_Math
A080H A084H
score_Math[0] score_Math[1]
函数调用时: void input_Scroes (float a[ ]) {
int i; for(i=0;i<M;i++)
scanf("%f", &a[i]); }
值从0变到M-1
A088H
score_Math[2]
#include<stdio.h> #define M 10 /*M代表学生人数*/ void main() {
float score_Math[M];
内存空间
…
A080H A084H A088H
score_Math[0] score_Math[1] score_Math[2]
A104H
score_Math[9]
注: 数组元素也叫“下标变量”。
03 班级成绩的最高分问题求解
【例】比较数组中的两个元素的大小,返回最小值。
#include<stdio.h> int min(int x,int y) {
int t; if(x< y)
t=x; else
t= y; return t; }
main()