C语言编程:请问为什么我的自定义函数全部无法执行,急急
#include<stdio.h>#include<string.h>#include<math.h>#defineNUM_std3#defineNUM_course3v...
#include<stdio.h>
#include<string.h>
#include <math.h>
#define NUM_std 3
#define NUM_course 3
void average1(float score[][NUM_course]);
void average2(float score[][NUM_course]);
void max(float score[][NUM_course]);
void fangcha();
void main()
{
int i,j;
float score[NUM_std][NUM_course]={0};
for(i=0;i<NUM_std;i++)
for(j=0;j<NUM_course;j++)
{
printf("input the mark of %dth courseof %dth student:",i,j);
scanf("%f",&score[i][j]);
}
void average1(float score[NUM_std][NUM_course]);
void average2(float score[NUM_std][NUM_course]);
void max(float score[NUM_std][NUM_course]);
void fangcha(float score[][NUM_course]);
}
void average1(float score[][NUM_course])
{
int j,i;
float total,average;
for(i=0;i<NUM_std;i++);
{
for(j=0;j<NUM_course;j++);
{
total+=score[i][j];
average=total/NUM_std;
printf("the %th student's average score is:",i,average);
}
total=0;average=0;
}
}
void average2(float score[][NUM_course])
{
int i,j;
float total,average;
for(j=0;j<NUM_course;j++);
{
for(i=0;i<NUM_std;i++);
{
total+=score[i][j];
average=total/NUM_course;
printf("the %dth course's average score is:",j,average);
}
total=0;average=0;
}
}
.........
程序无错 展开
#include<string.h>
#include <math.h>
#define NUM_std 3
#define NUM_course 3
void average1(float score[][NUM_course]);
void average2(float score[][NUM_course]);
void max(float score[][NUM_course]);
void fangcha();
void main()
{
int i,j;
float score[NUM_std][NUM_course]={0};
for(i=0;i<NUM_std;i++)
for(j=0;j<NUM_course;j++)
{
printf("input the mark of %dth courseof %dth student:",i,j);
scanf("%f",&score[i][j]);
}
void average1(float score[NUM_std][NUM_course]);
void average2(float score[NUM_std][NUM_course]);
void max(float score[NUM_std][NUM_course]);
void fangcha(float score[][NUM_course]);
}
void average1(float score[][NUM_course])
{
int j,i;
float total,average;
for(i=0;i<NUM_std;i++);
{
for(j=0;j<NUM_course;j++);
{
total+=score[i][j];
average=total/NUM_std;
printf("the %th student's average score is:",i,average);
}
total=0;average=0;
}
}
void average2(float score[][NUM_course])
{
int i,j;
float total,average;
for(j=0;j<NUM_course;j++);
{
for(i=0;i<NUM_std;i++);
{
total+=score[i][j];
average=total/NUM_course;
printf("the %dth course's average score is:",j,average);
}
total=0;average=0;
}
}
.........
程序无错 展开
2个回答
2013-06-27
展开全部
main函数中下面这一段
void average1(float score[NUM_std][NUM_course]);
void average2(float score[NUM_std][NUM_course]);
void max(float score[NUM_std][NUM_course]);
void fangcha(float score[][NUM_course]);
调用函数时,应该将参数实例化
average1(score);
average2(score);
max(score);
fangcha(score);
其实将自定义函数参数里的float去掉就行。
void average1(float score[NUM_std][NUM_course]);
void average2(float score[NUM_std][NUM_course]);
void max(float score[NUM_std][NUM_course]);
void fangcha(float score[][NUM_course]);
调用函数时,应该将参数实例化
average1(score);
average2(score);
max(score);
fangcha(score);
其实将自定义函数参数里的float去掉就行。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询