Home > Back-end >  With written in c language program, to solve?
With written in c language program, to solve?

Time:10-11

Define a structure array to save five students the following information: student id, name, gender, home address, 3 course results,

Requirements:

1. 5 students from the keyboard input data,

2. According to one of five students failed to pass the door and the number of failed in the all course,

3. The retrieval student id for NUM 3 course grades of students, NUM by keyboard input,

CodePudding user response:

If you want to learn, this topic is to write their own, question wrong post code
Hand in your homework to deceive the teacher, baidu's source code

CodePudding user response:

The operation is simple and simple, also said that difficult difficult, estimates that the teacher didn't speak a keyboard input of the abnormal situation needs, all kinds of after confirm the change of demand, ha ha. When using a keyboard too disgusted with text input source

CodePudding user response:

A simple code for reference,
 
#include
# define STUSIZE 5
Struct student
{
int num;
Char name [20].
Char sex [4];
Char homeaddr [50].
Float yuwen;
Float shuxue;
Float waiyu;
};

//input student information
Void input_stu (struct student p [])
{
int i;
For (I=0; i{
Printf (" please enter the first % d student information: \ n ", I + 1);
Printf (" please enter the student id: \ n ");
The scanf (" % d ", & amp; P [I] num);
Printf (" please input your name: \ n ");
The scanf (" % s ", & amp; P [I] name);
Printf (" please enter the gender: \ n ");
The scanf (" % s ", & amp; P [I] sex);
Printf (" please enter the address: \ n ");
The scanf (" % s ", & amp; P [I] homeaddr);
Printf (" please enter the language result: \ n ");
The scanf (" % f ", & amp; P [I] yuwen);
Printf (" please enter mathematics result: \ n ");
The scanf (" % f ", & amp; P [I]. Shuxue);
Printf (" please enter the foreign language achievement: \ n ");
The scanf (" % f ", & amp; P [I] waiyu);
}
}

//retrieve the student information
Void findstu (struct student stu [], int num)
{
int i=0;
for(i=0; i{
If (stu [I] num==num)
{
Printf (" the students three classes as: the language % % 2 f mathematics. 2 foreign language % f. 2 f \ n ", stu [I] yuwen, stu [I] shuxue, stu [I] waiyu);
break;
}
The else
{
Printf (" the student not found! \n");
}
}
}

Failed the//display the number of students
Void showstu (struct student stu [])
{
Int I, icount=0, acount=0;
for(i=0; i{
If (stu [I] yuwen & lt; 60 | | stu [I]. Shuxue & lt; 60 | | stu [I] waiyu & lt; 60)
{
Icount + +;
}
If (stu [I] yuwen & lt; 60 & amp; & Stu [I]. Shuxue & lt; 60 & amp; & Stu [I] waiyu & lt; 60)
{
Acount + +;
}
}
Printf (" the number of failed the one door is: % d all courses failed the number is: % d ", icount, acount);
}

Int main ()
{
Int n=0;
Struct student stu [STUSIZE]={0};
Input_stu (stu);
Printf (" please enter to retrieve student student id: \ n ");
The scanf (" % d ", & amp; n);
Findstu (stu, n);
Showstu (stu);

return 0;
}

CodePudding user response:

reference CHXCHXKKK reply: 3/f
post a simple code for reference,
 
#include
# define STUSIZE 5
Struct student
{
int num;
Char name [20].
Char sex [4];
Char homeaddr [50].
Float yuwen;
Float shuxue;
Float waiyu;
};

//input student information
Void input_stu (struct student p [])
{
int i;
For (I=0; i{
Printf (" please enter the first % d student information: \ n ", I + 1);
Printf (" please enter the student id: \ n ");
The scanf (" % d ", & amp; P [I] num);
Printf (" please input your name: \ n ");
The scanf (" % s ", & amp; P [I] name);
Printf (" please enter the gender: \ n ");
The scanf (" % s ", & amp; P [I] sex);
Printf (" please enter the address: \ n ");
The scanf (" % s ", & amp; P [I] homeaddr);
Printf (" please enter the language result: \ n ");
The scanf (" % f ", & amp; P [I] yuwen);
Printf (" please enter mathematics result: \ n ");
The scanf (" % f ", & amp; P [I]. Shuxue);
Printf (" please enter the foreign language achievement: \ n ");
The scanf (" % f ", & amp; P [I] waiyu);
}
}

//retrieve the student information
Void findstu (struct student stu [], int num)
{
int i=0;
for(i=0; i{
If (stu [I] num==num)
{
Printf (" the students three classes as: the language % % 2 f mathematics. 2 foreign language % f. 2 f \ n ", stu [I] yuwen, stu [I] shuxue, stu [I] waiyu);
break;
}
The else
{
Printf (" the student not found! \n");
}
}
}

Failed the//display the number of students
Void showstu (struct student stu [])
{
Int I, icount=0, acount=0;
for(i=0; i{
If (stu [I] yuwen & lt; 60 | | stu [I]. Shuxue & lt; 60 | | stu [I] waiyu & lt; 60)
{
Icount + +;
}
If (stu [I] yuwen & lt; 60 & amp; & Stu [I]. Shuxue & lt; 60 & amp; & Stu [I] waiyu & lt; 60)
{
Acount + +;
}
}
Printf (" the number of failed the one door is: % d all courses failed the number is: % d ", icount, acount);
}

Int main ()
{
Int n=0;
Struct student stu [STUSIZE]={0};
Input_stu (stu);
Printf (" please enter to retrieve student student id: \ n ");
The scanf (" % d ", & amp; n);
Findstu (stu, n);
Showstu (stu);

return 0;
}



 the scanf (" % s ", & amp; P [I] name); 
The scanf (" % s ", & amp; P [I] homeaddr);

These two lines of code to remove & amp; Is the address is right, because an array name ah

CodePudding user response:

Array can not, this is an array element, must be, p can not & amp; P [I] have to & amp;
  • Related