Dancing Partner Matching(Queue)[Solution introduction: the second video in 3.6] [Problem description] In a ball, when gentlemen and ladies come, they form a queue of gentlemen and a queue of ladies, respectively. When the ball starts, the gentlemen and ladies who come first should get partners first. A gentleman should be matched with a lady. Similarly, a lady can only match with a gentleman. Write programs to simulate the process of dancing partner matching. The maximal number of coming gentlemen or ladies is 30. [Basic requirements] 1) Use queues to solve this problem. [Example]Problem: Match coming gentlemen and ladies. What you need to show in the terminal(the back part is outputted by you and the blue part is inputted by the user, i.e., teacher): Please input coming dancers: Mark, male, 19 Alice, female, 21 Jenny, female, 23 Bob, male, 20 Andrew,male, 19 Julian, female, 18 Ivan, male, 22 Jeff, male, 21 Dancer partners are: Mark, Alice Bob, Jenny Andrew, Julian The following dancers do not have partners: Ivan, male, 22 Jeff, male, 21
The requirements of reports:
1.The
2.The source code with necessary comments
3.Test case and results (show the screenshot of your terminal);
4.Summary
4、Dancing Partner Matching(Queue)[Solution introduction: the second
video in 3.6]
[Problem description]
In a ball, when gentlemen and ladies come, they form a queue of gentlemen
and a queue of ladies, respectively. When the ball starts, the gentlemen and
ladies who come first should get partners first. A gentleman should be matched
with a lady. Similarly, a lady can only match with a gentleman. Write programs
to simulate the process of dancing partner matching.
The maximal number of coming gentlemen or ladies is 30.
[Basic requirements]
1) Use queues to solve this problem.
[Example]Problem: Match coming gentlemen and ladies.
What you need to show in the terminal(the back part is outputted by you
and the blue part is inputted by the user, i.e., teacher):
Please input coming dancers:
Mark, male, 19
Alice, female, 21
Jenny, female, 23
Bob, male, 20
Andrew,male, 19
Julian, female, 18
Ivan, male, 22
Jeff, male, 21
Dancer partners are:
Mark, Alice
Bob, Jenny
Andrew, Julian
The following dancers do not have partners:
Ivan, male, 22
Jeff, male, 21
Step by step
Solved in 3 steps with 3 images