救命啊,不太会用函数,帮忙改正下

来源:百度知道 编辑:UC知道 时间:2024/05/25 12:50:18
#include<stdio.h>
int main()
{
#define basicMatch 60

void number(float);
int i;
int sum=0;
int totalNumber=10;
float match,totalMatch;
float averageMatch;
{

for(i=1;i<=totalNumber;++i)

scanf("%f",&match);
if(match<basicMatch)
++sum;
totalMatch+=match;
}
averageMatch=totalMatch/totalNumber;

number(match);

return 0;
}
void number(float x)
{
int sum;
float averageMatch;

printf("the failure number is%i and averagenumber is %f\n",sum,averageMatch);
}
帮忙改正下

#include "stdafx.h"
#include<stdio.h>

int main()
{
#define basicMatch 60

void number(float, int);
int i;
int sum=0;
int totalNumber=10;
float match,totalMatch = 0.0;
float averageMatch;
{

for(i=1;i<=totalNumber;++i)
{

scanf("%f",&match);
if(match<basicMatch)
{
++sum;
totalMatch+=match;
}
}
}
averageMatch=totalMatch/sum;

number(averageMatch, sum);

return 0;
}
void number(float averageMatch, int sum)
{

printf("the failure number is%d and averagenumber is %f\n",sum,averageMatch);
}

纠正一下上面说的,宏定义可以在任何位置写,只是大家习惯在上面写,如果有什么问题Hi我。

宏定义不能在函数体内部。
函数定义和声明也不能在函数体内部,即便是主函数。你还是找本书看看吧。