Home > Back-end >  The small white, why I write this for average in each subject program compiled to run?
The small white, why I write this for average in each subject program compiled to run?

Time:10-09

#include
#include
#include
Int number;
The int class;
# define MAX_NUM 30
# define MAX_CLASS 6
# define MAX_LEN 10
Typedef struct student {
Long ID;
Char name [MAX_LEN];
Float * result [];
} STU.
Void sumaver1 (float * result []);
//void sumaver2 (float * result []);
Int main ()
{
STU STU.
int i;
Printf (" Input student number (n<30) : \ n ");
The scanf (" % d ", & amp; Number);
Printf (" Input course number (m<=6) : \ n ");
The scanf (" % d ", & amp; The class);
Printf (" Input the student 's ID, name and result: \ n ");
for(i=1; i<=number; I++) {
The scanf (" % ld % s % f ", & amp; Stu. ID & amp; Stu. Name, & amp; Stu. Result);
}
Sumaver1 (stu. Result);
return 0;
}
Void sumaver1 (float * result []) {
int i;
Int n;
Int sum [MAX_CLASS]={0};
Double business [MAX_CLASS]={0.0};
for(i=0; ifor(n=0; NThe sum [I] +=result [I] [n].
}
Business, [I]=1.0 * sum [I]/class;
}
for(i=0; iPrintf (" course % d: sum=% 0 f, aver.=% 0 f \ n ", I, the sum [I], business, [I]);
}
}
Small white sincerely ask, just didn't take long to learn c language, encountered such a situation very meng, autistic!

CodePudding user response:

Someone, and a big help me have a look

CodePudding user response:

Send an error message and have a look

CodePudding user response:

All the class

Gaicheng

Class1

Chinese input doesn 't last come out.

CodePudding user response:

Chinese input method is finally out

Had been not to come out

The class is a c + + keyword

All the class to class1 or something

CodePudding user response:

Don't have to use what define, haven't to this stage, with const first, simplify the procedure absolute, oneself is to understand the

CodePudding user response:

The
references 4 floor? Victor.?? Response:
Chinese input method is finally out

Had been not to come out

The class is a c + + keyword

All the class to class1 or something


Bosses, but after a change or not is to run after the data is entered, but not output any results

CodePudding user response:


Bosses after input the data with the card, digital input is not enough, nor the output, is it because my program to write wrong?

CodePudding user response:

refer to 2 floor don't know what kind of name, reply:
send a error message see

Send the bosses

CodePudding user response:

Do you require every division average

Or

Each student average

Ah

?

CodePudding user response:

It feels like is for every division

 # include 
Int number;
Int class1.
# define MAX_NUM 30
# define MAX_CLASS 6
# define MAX_LEN 10
Typedef struct student {
Long ID;
Char name [MAX_LEN];
Float result [MAX_NUM] [MAX_CLASS];
} STU.
Void sumaver1 (float result [MAX_NUM] [MAX_CLASS]);

Int main ()
{
STU STU.
int i,j;
Printf (" Input student number (n<30) : \ n ");
The scanf (" % d ", & amp; Number);
Printf (" Input course number (m<=6) : \ n ");
The scanf (" % d ", & amp; Class1);
Printf (" Input the student 's ID, name and result: \ n ");
for(i=0; iThe scanf (" % ld % s ", & amp; Stu. ID & amp; Stu. Name);
for(j=0; JThe scanf (" % f ", & amp; Stu. Result [I] [j]);
}
Sumaver1 (stu. Result);
return 0;
}

Void sumaver1 (float result [MAX_NUM] [MAX_CLASS]) {
int i;
int j;
Float sum [MAX_CLASS]={0};
Double business [MAX_CLASS]={0.0};
for(i=0; ifor(j=0; JThe sum [I] +=result [j] [I];
}
Business, [I]=sum [I]/number;
}
for(i=0; iPrintf (" course % d: sum=% 0 f, aver.=% 0 f \ n ", I + 1, sum [I], business, [I]);
}
}


For your reference

CodePudding user response:

The
references 9 floor? Victor.?? Response:
do you require every division average

Or

Each student average

Ah

?

Every division average, who helped me to see!

CodePudding user response:

The
references to the tenth floor? Victor.?? Response:
feeling that is for every division of the

 # include 
Int number;
Int class1.
# define MAX_NUM 30
# define MAX_CLASS 6
# define MAX_LEN 10
Typedef struct student {
Long ID;
Char name [MAX_LEN];
Float result [MAX_NUM] [MAX_CLASS];
} STU.
Void sumaver1 (float result [MAX_NUM] [MAX_CLASS]);

Int main ()
{
STU STU.
int i,j;
Printf (" Input student number (n<30) : \ n ");
The scanf (" % d ", & amp; Number);
Printf (" Input course number (m<=6) : \ n ");
The scanf (" % d ", & amp; nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related