试验报告群体类和群体数据.docVIP

  • 3
  • 0
  • 约2.45万字
  • 约 49页
  • 2020-11-21 发布于天津
  • 举报
10128学校代码60 《面向对象程序设计》实验报告 ( 据数和群体 目:群体类题 一二 〇 姓名:燕飞学生 十五 年 学 院:理学院 系 系数学别: 月一 算与计科学 专 业:信息 验目的一、实 2级班 :信计12-点类的声明和实、了解节1睿:侯任课教师 学习其使用方法,现 表类的声明和实、了解链2 习,现学其使用方法 、了解栈类的声明和实现,学习其使用方法3 、了解队列类的声明和实现,学习其使用方法4 、掌握对数组元素排序的方法5 、掌握对数组元素查找的方法6 二、实验内容 ,实现链表的基本操作。的节点类,并编写测试程序lab9_1.cpp、编写程序Node.h实现例9-51元素,,分别插入5A和Blab_2.cpp2、编写程序link.h实现例9-6的链表类,在测试程序中声明两个整型链表 的尾部。B中的元素加入A然后把3、编写程序queue.h,用链表实现队列(或栈),在测试程序lab9_3.cpp中声明一个整型队列(或栈)对象,插入5个整数,压入队列(或栈),再依次取出并显示出来。 4、(选做)声明course(课程)类,有属性:课程名char name[21]、成绩short score;在实验七的student类中增加属性;所修课程course,为课程类对象的链表。在测试程序中测试这个类,学生类与课程类关系如图 5、将直接插入排序、直接选择排序、冒泡排序、顺序查找函数封装到第九章的数组类中,作为成员函数,实现并测试这个类。 三、实验程序 1、 #ifndef NODE_CLASS #define NODE_CLASS template class T class Node { private: NodeT *next; public: T data; Node (const T item, NodeT* ptrnext = NULL); void InsertAfter(NodeT *p); NodeT *DeleteAfter(void); NodeT *NextNode(void) const; }; template class T NodeT::Node(const T item, NodeT* ptrnext) : data(item), next(ptrnext) {} template class T NodeT *NodeT::NextNode(void) const { return next; } template class T void NodeT::InsertAfter(NodeT *p) { p-next = next; next = p; } template class T NodeT *NodeT::DeleteAfter(void) { NodeT *tempPtr = next; if (next == NULL) return NULL; next = tempPtr-next; return tempPtr; } #endif #ifndef NODE_LIBRARY #define NODE_LIBRARY #include iostream #include cstdlib #include 9_5.h using namespace std; template class T NodeT *GetNode(const T item, NodeT *nextPtr = NULL) { NodeT *newNode; newNode = new NodeT(item, nextPtr); if (newNode == NULL) { cerr Memory allocation failure! endl; exit(1); } return newNode; } enum AppendNewline {noNewline,addNewline}; template class T void PrintList(NodeT *head, AppendNewline addnl = noNewline) { NodeT *currPtr = head; while(cur

文档评论(0)

1亿VIP精品文档

相关文档