(1) the custom design to meet the above requirements structure STU.
(2) from the keyboard input the basic information of the 30 students;
(3) statistics and output boy academic performance pass rate;
(4) statistical output and total number of girls younger than 18,
The following was written by myself, there is a problem, big problem, but also stuck not
#include
# define N 30
Struct students
{
int num;//student id
char name[20];//name
Int gender;//gender male M, female F
int age;//age
Float score;//achievement
Float grade;//fuck review
};
Int main ()
{
Struct students stu [30].
int i;
Float qualified=0; Qualified////
Float qualifiedf=0;//qualified//
for(i=0; I<30; I++)
{
The scanf (" % d % c % d % d % d % d ", & amp; Stu [I]. Num, & amp; Stu [I]. Name, & amp; Stu [I]. Gender, & amp; Stu [I]. Age, & amp; Stu [I] score, & amp; Stu [I] grade);
}
for(i=0; I<30; I++)
{
If (stu [I] score> 60 & amp; & Stu [I]. Gender=='M')
Qualified=qualified + 1;
}
Qualifiedf=qualified/30;
Printf (" % f ", qualifiedf);
return 0;
}
CodePudding user response:
& Stu [I]. NameThis is not right, with stu [I] name or & amp; Stu [I]. Name [0]
CodePudding user response:
The total number of less than 18 girls:int count=0;
for(i=0; I<30; I++)
{
If (stu [I] age<18 & amp; & Stu [I]. Gender=='F')
count++;
}
Printf (" % d \ n ", count);
CodePudding user response:
Reference:# include
# define N 30
Struct students
{
int num;//student id
char name[20];//name
//int gender;//gender male M, female F
Char gender;//gender male M, female F
int age;//age
Float score;//achievement
Float grade;//fuck review
};
Int main ()
{
Struct students stu [N].//stu [30]
int i;
Float qualified=0;//qualified
Float qualifiedf=0;//qualified rate
for(i=0; I{
//the scanf (" % d % c % d % d % d % d ",
The scanf (" % d % s % c % d % f, % f ",
& Stu [I]. Num, stu [I]. Name, & amp; Stu [I]. Gender, & amp; Stu [I]. Age, & amp; Stu [I] score, & amp; Stu [I] grade);
//& amp; Stu [I]. Num, & amp; Stu [I]. Name, & amp; Stu [I]. Gender, & amp; Stu [I]. Age, & amp; Stu [I] score, & amp; Stu [I] grade);
}
for(i=0; I{
//if (stu [I] score> 60 & amp; & Stu [I]. Gender=='M')
If (stu [I] score>=60 & amp; & Stu [I]. Gender=='M')
Qualified=qualified + 1;
}
//qualifiedf=qualified/30;
Qualifiedf=qualified/N.
Printf (" qualifiedf=% 2 f \ n ", qualifiedf);
int count=0;
for(i=0; I{
If (stu [I] age<18 & amp; & Stu [I]. Gender=='F')//total number of less than 18 girls
count++;
}
Printf (" count=% d \ n ", count);
return 0;
}