1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| struct structure_student {
char name[50];
int size;
bool sex; //sex=0 it's a boy -- sex=1 it's a girl
};
//****** function exchangeStudent *****
//* use to exchange the position of 2 students in a table of structure_student
void exchangeStudent(structure_student* studentS, int a, int b)
{
structure_student temp;
//put the data of the student a into the temp
strcpy(temp.name, studentS[a].name);
temp.size=studentS[a].size;
temp.sex=studentS[a].sex;
//put the data of the student b into the data of the student b
strcpy(studentS[a].name, studentS[b].name);
studentS[a].size=studentS[b].size;
studentS[a].sex=studentS[b].sex;
//put the data of the temp into the data of the student b
strcpy(studentS[b].name, temp.name);
studentS[b].size=temp.size;
studentS[b].sex=temp.sex;
} |
Partager