疯狂的指针

来源:百度知道 编辑:UC知道 时间:2024/05/28 04:09:42
题目: 有一个班4个学生,5门课。(1)求第一门课的平均分;(2)找出平均成绩在90分以上或全部课程成绩在85分以上的学生。分别编2个函数实现以上个要求。
要求:
(1) 不使用指针,使用数组和函数编写程序;
(2) 使用指向数组元素的指针变量来处理分数再编写一遍程序。
答:
第(2)问:

#include<stdio.h>
main()
{
float average_score(int, float (*score)[5]);
void student(float (*score)[5]);
int num[4]={00, 01, 02, 03}, i, j;
float score[4][5];
float average[4];
char course[5][10]={"course_1", "course_2", "course_3", "course_4", "course_5"};
for(i=0;i<4;i++)
{
printf("Now please input scores of NO.0%d:", i);
for(j=0;j<5;j++) scanf("%f", score+i*j+j);
}
printf("The average score of course NO.%d is %f\n", 1, average_score(1, score));
student(score);
}

float average_score(int n, fl

首先我觉得你的程序里有很多多余的东西。
我用的是c++2008 首先得在main函数前家void;还有就是scanf函数 里面换成*(score+i)+j比较好;还有就是你求出来的实际上是第二门课的平均分,那里应该是应该是average_score(0, score),你在运行一下吧,我试过了。

我刚刚拷过来,编译了一下,可以运行啊,我用的是win tc 和 vc
你再试试,应该是编译器的问题