Code:
#include <iostream>
#include <fstream>
using namespace std;
struct PERSON{
char name[10];
int height;
int weight;
int age;
PERSON *next;
};
void InputPerson(PERSON &p_sPerson);
void PrintPerson();
void swap(PERSON *x, PERSON *y);
void SortByHeight();
void SortByWeight();
void SortByAge();
PERSON *head;
int main()
{
ifstream file;
PERSON data;
char buf[20];
int menu;
file.open("girls generation.txt");
//read file
while(!file.eof())
{
file >> buf;
strcpy(data.naem, buf);
file >> buf;
data.height = atoi(buf);
file >> buf;
data.weight = atoi(buf);
file >> buf;
data.age = atoi(buf);
data.next=NULL;
//data load
InputPerson(data);
}
file.close();
//print data
PrintPerson();
while(true)
{
//menu
cout << "1. print order of height\n";
cout << "2. print order of weight\n";
cout << "3. print order of age\n";
cout << "4. finish the program\n";
cin >> menu;
if(menu == 4)
{
case 1:
SortByHeight();
PrintPerson();
break;
case 2:
SortByWeight();
PrintPerson();
break;
case 3:
SortByAge();
PrintPerson();
break;
default:
cout <<"You choose wrong number\n";
continue;
}
}
return 0;
}