#include
#include
using namespace std;
template //type表示整型
class person
{
private:
string name;
type number;
string gender;
type age;
string classRoom;
string health;
person *next;
public:
person(string _name,type _number,string _gender,type _age,string _classRoom,string _health)
{
name=_name;
number=_number;
gender=_gender;
age=_age;
classRoom=_classRoom;
health=_health;
};
person(person *_next=NULL)
{
next=_next;
}
};
template
class personList
{
private:
int length;
person *head,*current;
public:
personList()
{
head=new person;
current=head;
}
~personList()
{
for(int i=0;i<getLength(length);i++)
delete head;
delete current;
head=NULL;
current=NULL;
}
bool IsEmpty()
{
if(current->next==current)
return true;
else
return false;
}
int getLength(int m)
{
return m;
}
void addList(int m,person<type> & p)
{
for(int i=0;i<m;i++)
{
current=current->next;
}
current->next=head;
}
void sortList(int m,int n)
{
int count=0;
for(int i=0;i<m;i++)
for(int j=0;j<n;j++)
{
while(!IsEmpty())
{
current=current->next;
person<type> *temporary=new person<type>;
temporary=current;
++count;
if(count==n-1)
{
cout<<"\n";
cout<<temporary->name<<" "<<temporary->number<<" "<<temporary->gender<<" "<<temporary->age<<" ";
cout<<temporary->classRoom<<" "<<temporary->health<<endl;
delete temporary;
}
current->next=current->next->next;
}
}
count=0;
}
};
int main()
{
person *every=new person;
personList pList=new personList;
int m,n;
cin>>m>>n;
string name;
int number;
string gender;
int age;
string classRoom;
string health;
for(int i=0;i<m;i++)
{
cin>>name>>number>>gender>>age>>classRoom>>health;
every[i]=new person<int>(name,number,gender,age,classRoom,health);
pList->addList(&m,every[i]);
}
pList.sortList(&m,&n);
getLength(&m);
return 0;
}