1、数据结构课程设计报告 简单的舞会简单的舞会统计统计问题问题 一、题目要求: 运用数据结构知识,编写代码,实现: 1. 对一个舞会所有来宾性别录入,并输出参加舞会总人数以 及对应编号的性别基信息。 2. 实现在第几轮舞会结束,对来宾跳舞总次数的统计 3. 查询某名男士和某名女士跳舞的总次数。 二、实验设计代码如下: Hwuban.h #include #ifndef Hwuban_H #define Hwuban_H const bool TURE=1; const bool FAULT=0; class Node/链式堆栈的节点类 public: Node();/构造函数重载 1 Node(i
2、nt , int , int ,Node *);/构造函数重载 2 void const get_data(int /取节点数据 void put_data(int , int ,int );/置节点数据 bool put_next(Node *);/置节点的前驱节点域 bool put_prior(Node *);/置结点的后继结点域 Node* const get_next()const;/取结点的前驱结点域 Node* const get_prior()const;/取结点的后继结点域 private: Node *next; Node *prior; int minute; int s
3、econd; int num; ; class Queue public: Queue();/堆栈类的构造函数 int get_length(void);/取堆栈的长度 bool push(int , int , int );/数据压栈 bool pop(int /数据出栈 void print(void); int const seach(int );/搜索堆栈数据 protected: Node base;/根节点 Node *top;/顶节点 int length; ; #endif hanshu1.cpp #include #include “Hwuban.h“ using names
4、pace std; Node:Node() minute=NULL; second=NULL; num=0; next=NULL; prior=NULL; Node:Node(int x, int y, int z ,Node *p) minute=x; second=y; num=z; next=NULL; prior=p; void const Node:get_data(int y=second; z=num; void Node:put_data(int x, int y, int z) minute=x; second=y; num=z; bool Node:put_next(Node *n) next=n; return TURE; bool Node:put_prior(Nod