C++错误求高手帮忙看下什么原因

2025-03-09 09:20:31
推荐回答(2个)
回答1:

void numave(double* res, int* num)
如果我没记错的话,实现的时候需要写上你的变量名,以及变量类型。
不写变量名的话就成了声明了把。。
其他的应该也是一样的把

#include
using namespace std;
#define M 4
#define N 5
char stu[N][10];
double res[M][N];
int num[M];
void numave(double res[][N],int num[])
{
int x,y;
double ave;
cout<<"每位同学的平均成绩";
for(x=0;x {
ave=0.0;
for(y=0;y ave+=res[x][y];
ave=ave/5.0;
cout< }

}
void stuave(double res[][N],char stu[][10])
{
int x,y;
double ave;
cout<<"每门课程的平均成绩";
for(y=0;y {
ave=0.0;
for(x=0;x ave+=res[x][y];
ave=ave/4.0;
cout<
}
}
void search(double res[][N],char stu[][10],int num[])
{
int x,y,z;
double ave;
for(x=0;x {
z=0;
ave=0.0;
for(y=0;y {
ave+=res[x][y];
if(res[x][y]<60.0) z++;
}
if(z>2)
{
ave=ave/4.0;
cout<<"AAAA"< for(y=0;y cout< cout< }
}

}
void findmax(double res[][N],char stu[][10],int num[])
{
int x,y,a,b;
double max=0.0;
for(x=0;x for(y=0;y {
if(res[x][y]>max)
{max=res[x][y];a=x;b=y;}
}
cout<<"AA"<}
void main()
{

int i,j;
cout<<"请输入对应的学号(空格隔开)"< for(i=0;i cin>>num[i];
cout<<"请输入课程名(空格隔开)"< for(i=0;i cin>>stu[i][10];
cout<<"请输入对应的成绩(空格隔开)"< for(i=0;i for(j=0;j cin>>res[i][j];
numave(res,num);
stuave(res,stu);
search(res,stu,num);
findmax(res,stu,num);

}

回答2:

void stuave(double*,char*)

少个大括号
local function definitions are illegal,意思是函数定义非法。你在函数中定义了函数