Could it be the place to write the wrong ah//marked points
# include "stdio.h"//calculate various average
# define Pnum 3//person
# define Snum 3//subject
Float avr (float data [])
{
float sum=0;
int i=0;
Do {
The sum +=data [i++];
} while (I==sizeof (data)/(sizeof (float)));//markers in
Return the sum/I;
}
//int Max (float * data)
Int main ()
{
Float stu [Pnum], gra [Snum], list [Pnum] [Snum];
Int I, j;
//enter
For (I=0; I & lt; Pnum; I++) {
For (j=0; J & lt; Snum; J++) {
Scanf_s (" % f ", * (the list + I) + j));
}
}
For (I=0; I & lt; Pnum; I++) {
For (j=0; J & lt; Snum; J++) {
Printf (" % 6.1 f ", * (* (the list + I) + j));
If (j==Snum - 1) {
printf("\n");
}
}
}
For (I=0; I & lt; Pnum; I++) {
For (j=0; J & lt; Snum; J++) {
Gra [j]=list [I] [j];//each student's report card
}
Printf (" % d student of average can be divided into: % 5.2 f \ n ", I + 1, avr (gra));
}
For (j=0; J & lt; Snum; J++) {
For (I=0; I & lt; Pnum; I++) {
Stu [I]=list [I] [j];
}
Printf (" % d average of the course can be divided into: % 5.2 f \ n ", j + 1, avr (stu));
}
return 0;
CodePudding user response:
Is write wrong,Writing array name parameter is actually a compatible type of pointer, sizeof is a pointer to the size of the array size or other incoming parameters, or global come in an array, or variable incoming array encapsulated in the structure,
CodePudding user response:
According to the thinking of the building Lord, modified as follows, for your reference:# include & lt; Stdio. H>
# define Pnum 3//person
# define Snum 3//subject
Float avr (float data [], int num)//function increase or decrease in a parameter
{
float sum=0;
int i=0;
Do {
The sum +=data [i++];
} while (I & lt; Num);//==sizeof (data)/(sizeof (float)));//markers in
Return the sum/I;
}
//int Max (float * data)
Int main (int arg c, char * argv [])
{
Float stu [Pnum], gra [Snum], list [Pnum] [Snum];
Int I, j;
//enter
For (I=0; I & lt; Pnum; I++) {
For (j=0; J & lt; Snum; J++) {
The scanf (" % f ", * (the list + I) + j));
}
}
For (I=0; I & lt; Pnum; I++) {
For (j=0; J & lt; Snum; J++) {
Printf (" % 6.1 f ", * (* (the list + I) + j));
If (j==Snum - 1) {
printf("\n");
}
}
}
For (I=0; I & lt; Pnum; I++) {
For (j=0; J & lt; Snum; J++) {
Gra [j]=list [I] [j];//each student's report card
}
Printf (" % d student of average can be divided into: % 5.2 f \ n ", I + 1, avr (gra, Snum));
}
For (j=0; J & lt; Snum; J++) {
For (I=0; I & lt; Pnum; I++) {
Stu [I]=list [I] [j];
}
Printf (" % d average of the course can be divided into: % 5.2 f \ n ", j + 1, avr (stu, Pnum));
}
return 0;
}
CodePudding user response: