#include <iostream>
using namespace std;
#include <string>
struct LinkNode {
string s_name;
int s_num;
string s_sex;
int s_age;
string s_banji;
string s_jiankang;
LinkNode* link;
LinkNode() {
link = NULL;
}
LinkNode(string name, int num, string sex,int age, string banji, string jiankang) {
s_name = name;
s_num = num;
s_sex = sex;
s_age = age;
s_banji = banji;
s_jiankang = jiankang;
link = NULL;
}
};
class LineList {
public:
int length;
LinkNode* first;
public:
LineList() {}
LineList(int n) {
length = n;
first = new LinkNode();
LinkNode* current = first;
for (int i = 0; i < length; i++) {
string name;
int num;
string sex;
int age;
string banji;
string jiankang;
cin >> name;
cin >> num;
cin >> sex >> age >> banji >> jiankang;
LinkNode* newnode = new LinkNode(name,num,sex,age,banji,jiankang);
current->link = newnode;
current = newnode;
}
}
void LetGame(int m) {
LinkNode* current_qian;
LinkNode* current = first;
for (int i = 1; i <= length; i++) {
current = current->link;
}
current->link = first->link;
current = first;
while (1) {
for (int i = 1; i <= m; i++) {
current_qian = current;
current = current->link;
if (i == m) {
cout << current->s_name << " "
<< current->s_num << " "
<< current->s_sex << " "
<< current->s_age << " "
<< current->s_banji << " "
<< current->s_jiankang << endl;
current_qian->link = current->link;
delete current;
length--;
current = current_qian;
}
}
if (length == 0)break;
}
}
};
int main() {
int n1, n2;
cin >> n1 >> n2;
LineList L(n1);
L.LetGame(n2);
return 0;
}
|