ImageVerifierCode 换一换
格式:DOC , 页数:47 ,大小:1.01MB ,
资源ID:9512446      下载积分:12 金币
验证码下载
登录下载
邮箱/手机:
图形码:
验证码: 获取验证码
温馨提示:
支付成功后,系统会自动生成账号(用户名为邮箱或者手机号,密码是验证码),方便下次登录下载和查询订单;
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

开通VIP
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.zixin.com.cn/docdown/9512446.html】到电脑端继续下载(重复下载【60天内】不扣币)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

开通VIP折扣优惠下载文档

            查看会员权益                  [ 下载后找不到文档?]

填表反馈(24小时):  下载求助     关注领币    退款申请

开具发票请登录PC端进行申请。


权利声明

1、咨信平台为文档C2C交易模式,即用户上传的文档直接被用户下载,收益归上传人(含作者)所有;本站仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。所展示的作品文档包括内容和图片全部来源于网络用户和作者上传投稿,我们不确定上传用户享有完全著作权,根据《信息网络传播权保护条例》,如果侵犯了您的版权、权益或隐私,请联系我们,核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
2、文档的总页数、文档格式和文档大小以系统显示为准(内容中显示的页数不一定正确),网站客服只以系统显示的页数、文件格式、文档大小作为仲裁依据,个别因单元格分列造成显示页码不一将协商解决,平台无法对文档的真实性、完整性、权威性、准确性、专业性及其观点立场做任何保证或承诺,下载前须认真查看,确认无误后再购买,务必慎重购买;若有违法违纪将进行移交司法处理,若涉侵权平台将进行基本处罚并下架。
3、本站所有内容均由用户上传,付费前请自行鉴别,如您付费,意味着您已接受本站规则且自行承担风险,本站不进行额外附加服务,虚拟产品一经售出概不退款(未进行购买下载可退充值款),文档一经付费(服务费)、不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
4、如你看到网页展示的文档有www.zixin.com.cn水印,是因预览和防盗链等技术需要对页面进行转换压缩成图而已,我们并不对上传的文档进行任何编辑或修改,文档下载后都不会有水印标识(原文档上传前个别存留的除外),下载后原文更清晰;试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓;PPT和DOC文档可被视为“模板”,允许上传人保留章节、目录结构的情况下删减部份的内容;PDF文档不管是原文档转换或图片扫描而得,本站不作要求视为允许,下载前可先查看【教您几个在下载文档中可以更好的避免被坑】。
5、本文档所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用;网站提供的党政主题相关内容(国旗、国徽、党徽--等)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
6、文档遇到问题,请及时联系平台进行协调解决,联系【微信客服】、【QQ客服】,若有其他问题请点击或扫码反馈【服务填表】;文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“【版权申诉】”,意见反馈和侵权处理邮箱:1219186828@qq.com;也可以拔打客服电话:4009-655-100;投诉/维权电话:18658249818。

注意事项

本文(实验报告群体类和群体数据模板.doc)为本站上传会员【w****g】主动上传,咨信网仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知咨信网(发送邮件至1219186828@qq.com、拔打电话4009-655-100或【 微信客服】、【 QQ客服】),核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载【60天内】不扣币。 服务填表

实验报告群体类和群体数据模板.doc

1、学校代码: 10128 学 号: 20905060 《面向对象程序设计》试验汇报 ( 题 目: 群体类和群体数据 学生姓名: 燕飞 学 院: 理学院 系 别: 数学系 专 业: 信息与计算科学 班 级: 信计12-2 任课老师: 侯睿 二 〇 一 五 年 十 一 月 一、 试验目 1、 了解节点类申明和实现, 学习其使用方法 2、 了解链表类申明和实现,

2、学习其使用方法 3、 了解栈类申明和实现, 学习其使用方法 4、 了解队列类申明和实现, 学习其使用方法 5、 掌握对数组元素排序方法 6、 掌握对数组元素查找方法 二、 试验内容 1、 编写程序Node.h实现例9-5节点类, 并编写测试程序lab9_1.cpp, 实现链表基础操作。 2、 编写程序link.h实现例9-6链表类, 在测试程序lab_2.cpp中申明两个整型链表A和B, 分别插入5元素, 然后把B中元素加入A尾部。 3、 编写程序queue.h, 用链表实现队列(或栈), 在测试程序lab9_3.cpp中申明一个整型队列(或栈)对象, 插入5个整数, 压入队列

3、或栈), 再依次取出并显示出来。 4、 (选做)申明course(课程)类, 有属性: 课程名char name[21]、 成绩short score; 在试验七student类中增加属性; 所修课程course, 为课程类对象链表。在测试程序中测试这个类, 学生类与课程类关系如图 5、 将直接插入排序、 直接选择排序、 冒泡排序、 次序查找函数封装到第九章数组类中, 作为组员函数, 实现并测试这个类。 三、 试验程序 1、 #ifndef NODE_CLASS #define NODE_CLASS template class Node {

4、 private: Node *next; public: T data; Node (const T& item, Node* ptrnext = NULL); void InsertAfter(Node *p); Node *DeleteAfter(void); Node *NextNode(void) const; }; template Node::Node(const T& item, Node

5、>* ptrnext) : data(item), next(ptrnext) {} template Node *Node::NextNode(void) const { return next; } template void Node::InsertAfter(Node *p) { p->next = next; next = p; } template Node *Node::DeleteAfter(void) { Node

6、tempPtr = next; if (next == NULL) return NULL; next = tempPtr->next; return tempPtr; } #endif #ifndef NODE_LIBRARY #define NODE_LIBRARY #include #include #include "9_5.h" using namespace std; template Node *GetNode(const T& i

7、tem, Node *nextPtr = NULL) { Node *newNode; newNode = new Node(item, nextPtr); if (newNode == NULL) { cerr << "Memory allocation failure!" << endl; exit(1); } return newNode; } enum AppendNewline {noNewline,addNewline}; template

8、ss T> void PrintList(Node *head, AppendNewline addnl = noNewline) { Node *currPtr = head; while(currPtr != NULL) { if(addnl == addNewline) cout << currPtr->data << endl; else cout << currPtr->data << " ";

9、 currPtr = currPtr->NextNode(); } } template int Find(Node *head, T& item, Node* &prevPtr) { Node *currPtr = head; prevPtr = NULL; while(currPtr != NULL) { if (currPtr->data == item) return 1; prevPtr = currPtr; currPtr

10、 currPtr->NextNode(); } return 0; } template void InsertFront(Node* & head, T item) { head = GetNode(item,head); } template void InsertRear(Node* & head, const T& item) { Node *newNode, *currPtr = head; if (currPtr == NULL) Inser

11、tFront(head,item); else { while(currPtr->NextNode() != NULL) currPtr = currPtr->NextNode(); newNode = GetNode(item); currPtr->InsertAfter(newNode); } } template void DeleteFront(Node* & head) { Node *p = head;

12、 if (head != NULL) { head = head->NextNode(); delete p; } } template void Delete (Node* & head, T key) { Node *currPtr = head, *prevPtr = NULL; if (currPtr == NULL) return; while (currPtr != NULL && currPtr->data != key)

13、 { prevPtr = currPtr; currPtr = currPtr->NextNode(); } if (currPtr != NULL) { if(prevPtr == NULL) head = head->NextNode(); else prevPtr->DeleteAfter(); delete currPtr; } } template void InsertOrder(Nod

14、e* & head, T item) { Node *currPtr, *prevPtr, *newNode; prevPtr = NULL; currPtr = head; while (currPtr != NULL) { if (item < currPtr->data) break; prevPtr = currPtr; currPtr = currPtr->NextNode(); } if (prevPtr

15、 NULL) InsertFront(head,item); else { newNode = GetNode(item); prevPtr->InsertAfter(newNode); } } template void ClearList(Node * &head) { Node *currPtr, *nextPtr; currPtr = head; while(currPtr != NULL) {

16、nextPtr = currPtr->NextNode(); delete currPtr; currPtr = nextPtr; } head = NULL; } #endif #include #include "9_5.h" #include "node.h" using namespace std; int main() { Node *head = NULL, *prevPtr, *delPtr; int i, key, item; fo

17、r (i=0;i < 10;i++) { cin>>item; InsertFront(head, item); } cout << "List: "; PrintList(head,noNewline); cout << endl; cout << "请输入一个需要删除整数: "; cin >> key; prevPtr = head; while (Find(head,key,prevPtr) != NULL) { if(prevPtr == NUL

18、L) head = head->NextNode(); else delPtr=prevPtr->DeleteAfter(); delete delPtr; } cout << "List: "; PrintList(head,noNewline); cout << endl; ClearList(head); } 2、 #include "link.h" int main() { LinkedList A, B; for(int

19、i=0;i<5;i++) { A.InsertRear(2*i+1); B.InsertRear(2*i+2); } A.Reset(); cout << "链表A元素为: " ; while(!A.EndOfList()) { cout << A.Data() << " "; A.Next(); } cout << endl; B.Reset(); cout << "链表B元素为: " ; while(!B.EndOfList()) { cout << B.Data() << " "; B.Ne

20、xt(); } cout << endl; cout << "把B中元素插入A中..." << endl; B.Reset(); while(!B.EndOfList()) { A.InsertRear(B.Data()); B.Next(); } A.Reset(); cout << "此时, 链表A元素为: " ; while(!A.EndOfList()) { cout << A.Data() << " "; A.Next(); } cout << endl; } #ifndef LINKEDLIST_C

21、LASS #define LINKEDLIST_CLASS #include #include using namespace std; #ifndef NULL const int NULL = 0; #endif // NULL #include "9-3.h template class LinkedList { private: Node *front, *rear; Node *prevPtr, *currPtr; int size;

22、 int position; Node *GetNode(const T& item,Node *ptrNext=NULL); void FreeNode(Node *p); void CopyList(const LinkedList& L); public: LinkedList(void); LinkedList(const LinkedList& L); ~LinkedList(void); LinkedList& operator=

23、const LinkedList& L); int ListSize(void) const; int ListEmpty(void) const; void Reset(int pos = 0); void Next(void); int EndOfList(void) const; int CurrentPosition(void) const; void InsertFront(const T& item); void InsertRear(const T& item

24、); void InsertAt(const T& item); void InsertAfter(const T& item); T DeleteFront(void); void DeleteAt(void); T& Data(void); void ClearList(void); }; template Node *LinkedList::GetNode(const T& item, Node<

25、T>* ptrNext) { Node *p; p = new Node(item,ptrNext); if (p == NULL) { cout << "Memory allocation failure!\n"; exit(1); } return p; } template void LinkedList::FreeNode(Node *p) { delete p; } template void LinkedList:

26、CopyList(const LinkedList& L) { Node *p = L.front; int pos; while (p != NULL) { InsertRear(p->data); p = p->NextNode(); } if (position == -1) return; prevPtr = NULL; currPtr = front; for (pos = 0; pos != position; pos++) {

27、 prevPtr = currPtr; currPtr = currPtr->NextNode(); } } template LinkedList::LinkedList(void): front(NULL), rear(NULL), prevPtr(NULL),currPtr(NULL), size(0), position(-1) {} template LinkedList::LinkedList(const LinkedList& L) { front = rear =

28、 NULL; prevPtr = currPtr = NULL; size = 0; position = -1; CopyList(L); } template void LinkedList::ClearList(void) { Node *currPosition, *nextPosition; currPosition = front; while(currPosition != NULL) { nextPosition = currPosition->NextNode();

29、 FreeNode(currPosition); currPosition = nextPosition; } front = rear = NULL; prevPtr = currPtr = NULL; size = 0; position = -1; } template LinkedList::~LinkedList(void) { ClearList(); } template LinkedList& LinkedList::operator=(

30、const LinkedList& L) { if (this == &L) return *this; ClearList(); CopyList(L); return *this; } template int LinkedList::ListSize(void) const { return size; } template int LinkedList::ListEmpty(void) const { return size == 0; } te

31、mplate void LinkedList::Next(void) { if (currPtr != NULL) { prevPtr = currPtr; currPtr = currPtr->NextNode(); position++; } } template int LinkedList::EndOfList(void) const { return currPtr == NULL; } template int Link

32、edList::CurrentPosition(void) const { return position; } template void LinkedList::Reset(int pos) { int startPos; if (front == NULL) return; if (pos < 0 || pos > size-1) { cerr << "Reset: Invalid list position: " << pos << endl; return;

33、 } if(pos == 0) { prevPtr = NULL; currPtr = front; position = 0; } else { currPtr = front->NextNode(); prevPtr = front; startPos = 1; for(position=startPos; position != pos; position++) { prevPtr = currPtr;

34、 currPtr = currPtr->NextNode(); } } } template T& LinkedList::Data(void) { if (size == 0 || currPtr == NULL) { cerr << "Data: invalid reference!" << endl; exit(1); } return currPtr->data; } template void LinkedList::Inse

35、rtFront(const T& item) { if (front != NULL) Reset(); InsertAt(item); } template void LinkedList::InsertRear(const T& item) { Node *newNode; prevPtr = rear; newNode = GetNode(item); if (rear == NULL) front = rear = newNode; else {

36、 rear->InsertAfter(newNode); rear = newNode; } currPtr = rear; position = size; size++; } template void LinkedList::InsertAt(const T& item) { Node *newNode; if (prevPtr == NULL) { newNode = GetNode(item,front); front = newNode

37、 } else { newNode = GetNode(item); prevPtr->InsertAfter(newNode); } if (prevPtr == rear) { rear = newNode; position = size; } currPtr = newNode; size++; } template void LinkedList::InsertAfter(const T& ite

38、m) { Node *p; p = GetNode(item); if (front == NULL) { front = currPtr = rear = p; position = 0; } else { if (currPtr == NULL) currPtr = prevPtr; currPtr->InsertAfter(p); if (currPtr == rear) { rear = p;

39、 position = size; } else position++; prevPtr = currPtr; currPtr = p; } size++; } template T LinkedList::DeleteFront(void) { T item; Reset(); if (front == NULL) { cerr << "Invalid deletion!" << endl; exit(1);

40、 } item = currPtr->data; DeleteAt(); return item; } template void LinkedList::DeleteAt(void) { Node *p; if (currPtr == NULL) { cerr << "Invalid deletion!" << endl; exit(1); } if (prevPtr == NULL) { p = front; fr

41、ont = front->NextNode(); } else p = prevPtr->DeleteAfter(); if (p == rear) { rear = prevPtr; position--; } currPtr = p->NextNode(); FreeNode(p); size--; } #endif 3、 #ifndef QUEUE_CLASS #define QUEUE_CLASS #include #incl

42、ude using namespace std; #include "link.h" template class Queue { private: LinkedList queueList; public: Queue(void); void QInsert(const T& elt); T QDelete(void); T QFront(void); int QLength(void) const;

43、 int QEmpty(void) const; void QClear(void); }; template Queue::Queue(void) {} template int Queue::QLength(void) const { return queueList.ListSize(); } template int Queue::QEmpty(void) const { return queueList.ListEmpty(); } t

44、emplate void Queue::QClear(void) { queueList.ClearList(); } template void Queue::QInsert(const T& elt) { queueList.InsertRear(elt); } template T Queue::QDelete(void) { if (queueList.ListEmpty()) { cerr << "Calling QDelete

45、for an empty queue!" << endl; exit(1); } return queueList.DeleteFront(); } template T Queue::QFront(void) { if (queueList.ListEmpty()) { cerr << "Calling QFront for an empty queue!" << endl; exit(1); } queueList.Reset();

46、return queueList.Data(); } #endif #ifndef LINKEDLIST_CLASS #define LINKEDLIST_CLASS #include #include using namespace std; #ifndef NULL const int NULL = 0; #endif #include "9-3.h" template class LinkedList { private: Node *front, *rear;

47、 Node *prevPtr, *currPtr; int size; int position; Node *GetNode(const T& item,Node *ptrNext=NULL); void FreeNode(Node *p); void CopyList(const LinkedList& L); public: LinkedList(void); LinkedList(const LinkedList& L); ~L

48、inkedList(void); LinkedList& operator= (const LinkedList& L); int ListSize(void) const; int ListEmpty(void) const; void Reset(int pos = 0); void Next(void); int EndOfList(void) const; int CurrentPosition(void) const; void InsertFront(cons

49、t T& item); void InsertRear(const T& item); void InsertAt(const T& item); void InsertAfter(const T& item); T DeleteFront(void); void DeleteAt(void); T& Data(void); void ClearList(void); }; template Node *LinkedList::GetNode(const T&

50、 item, Node* ptrNext) { Node *p; p = new Node(item,ptrNext); if (p == NULL) { cout << "Memory allocation failure!\n"; exit(1); } return p; } template void LinkedList::FreeNode(Node *p) { delete p; } template void Li

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2025 宁波自信网络信息技术有限公司  版权所有

客服电话:4009-655-100  投诉/维权电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服