在下面主函数里定义了一个数组.请问怎么把成绩存进数组里呢?谢谢.
#include<stdio.h>
#define N 10
struct student
{
int score;
};struct student stu[N];
void state( struct student* stu, int n );
void main()
{
int i;
int score[10];
for ( i = 0; i < N; ++i )
{
printf( "请输入第%d个学员的成绩: ", i + 1 );
scanf( "%d", &stu[i].score );
}
state( stu, N );
}
void state( struct student* stu, int n )
{
int sum, max, min;
int i;
sum = 0;
max =stu[0].score;
min = stu[0].score;
for( i = 0; i < n; ++i )
{
sum += stu[i].score;
max = stu[i].score > max ? stu[i].score : max;
min = stu[i].score < min ? stu[i].score : min;
}
printf( "平均分:%d\n最高分:%d\n最低分%d\n总分%d\n", sum/N, max, min,sum);
}
[此贴子已经被作者于2007-3-21 20:31:11编辑过]
----------------解决方案--------------------------------------------------------
自己顶吧.
----------------解决方案--------------------------------------------------------
在主主函数里面,定义数组没有必要
----------------解决方案--------------------------------------------------------
score[i]=stu[i].score;
我也觉得没有必要.
----------------解决方案--------------------------------------------------------