能帮忙看一下,哪里有问题吗?
数组和函数的成绩计算
不会改,一直有错,看不太明白
aver1 和 aver2 你定义的都是float类型,就不能当数组使用
你要定义成 float aver1[3], aver2[3]; 才可以
另外 ave函数调用,传 数组名 score1,score2,score3,不要带 方括号
aver1和aver2的定义有问题,修改如下:
float aver1[3],aver2[3];
ave函数输入参数有问题,,不明白私聊哈!修改如下所示:
aver2[0]=ave(score1,n);
aver2[1]=ave(score2,n);
aver2[2]=ave(score3,n);
不知道你这个问题是否已经解决, 如果还没有解决的话:ISO(国际标准化组织(International Standard Organization))将C语言分为三个不同类型集合: 函数类型、对象类型和不完全类型,具体说明如下所示:
C语言所有数据类型如下图所示:
在C99标准中对不完全类型描述如下:
The void type comprises an empty set of values; it is an incomplete type that cannot be completed. (C99 6.2.5/19)
An array type of unknown size is an incomplete type. It is completed, for an identifier of that type, by specifying the size in a later declaration (with internal or external linkage). A structure or union type of unknown content (as described in 6.7.2.3) is an incomplete type. It is completed, for all declarations of that type, by declaring the same structure or union tag with its defining content later in the same scope.(C99 6.2.5/22)
总结讲,C/C++中不完全类型有三种不同形式:void、未指定长度的数组以及具有非指定内容的结构和联合。void类型与其他两种类型不同,因为它是无法完成的不完全类型,并且它用作特殊函数返回和参数类型。
不完全类型是暂时没有完全定义好的类型,编译器不知道这种类型该占几个字节的存储空间,例如以下定义方式:
int str[]; //不完全类型数组str定义
…
int str[10]; //定义str数组完整的类型信息
再举个例子,在头*.h文件中声明结构:typedef struct __list *list_t;,最终在*.c文件中定义如下:
struct __list {
struct __list *prev;
struct __list *next;
viud *data;
};
此时,结构体变量*list_t就属于不完全类型,不完全类型不包含具体的类型信息,所以在未完整定义前不能通过sizeof来获知大小,并且不完全类型定义不适合局部变量。
我需要看一下你的代码才能确定问题所在。请提供你的代码。