struct employee{
char name[20];
int ID;
double salary;
char address;
};
void main(){
employee X[20];
for(int i=0;i%26lt;20;i++){
cin%26gt;%26gt;X[i].ID;
cin%26gt;%26gt;X[i].name;
cin%26gt;%26gt;X[i].salary;
cin%26gt;%26gt;X[i].address;
}
}
i want to sort the data by X[i].name ,, how ??
Help in C++ ,, sorting structure array by alphabetical :S?
make an extra employee.
compare date x[0] to x[1] if x[0] is greater, switch them.
compare date x[1] to x[2] if x[2] is greater, switch them.
go over the array 19 times, (the size of the array -1)
This is the laziest way of sorting.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment