数据结构课程设计.小弟才学数据结构,学得很是不好现在有两道设计题,希望前辈帮我做下,要完整,执行能通过的,追分150分没有人会吗没有人会吗没有人会吗没有人会吗

来源:学生作业帮助网 编辑:作业帮 时间:2024/04/30 07:44:45
数据结构课程设计.小弟才学数据结构,学得很是不好现在有两道设计题,希望前辈帮我做下,要完整,执行能通过的,追分150分没有人会吗没有人会吗没有人会吗没有人会吗

数据结构课程设计.小弟才学数据结构,学得很是不好现在有两道设计题,希望前辈帮我做下,要完整,执行能通过的,追分150分没有人会吗没有人会吗没有人会吗没有人会吗
数据结构课程设计.
小弟才学数据结构,学得很是不好
现在有两道设计题,希望前辈帮我做下,要完整,执行能通过的,追分150分
没有人会吗没有人会吗没有人会吗没有人会吗

数据结构课程设计.小弟才学数据结构,学得很是不好现在有两道设计题,希望前辈帮我做下,要完整,执行能通过的,追分150分没有人会吗没有人会吗没有人会吗没有人会吗
源代码含有四个文件,datastruct.h是数据结构的定义;ListOper.h是线性表操作函数的声明;ListOper.cpp是线性表操作函数的定义;main.cpp是主单元含有主函数和字符串分析函数.
datastruct.h
typedef struct list
{
int c; //多项式的项数
int e; //多项式的指数
struct list *next; //下一结点
};
typedef struct list *LinkList;
typedef struct list Node;
下面是线性表的操作相关函数声明,对应文件ListOper.h:
//File: ListOper.h
#ifndef DATASTRUCT
#define DATASTRUCT
#include "datastruct.h"
#endif
//some functions declaretioin
bool CreateList(LinkList &L);
Node *CreateNode(int e, int c);
void FreeList(LinkList &L);
void SortList(LinkList &L);
void DeleteNextNode(Node *d);
void SweepNextNode(Node *s);
void OutPutList(LinkList &L);
相关函数的实现,对应文件ListOper.cpp:
//File: ListOper.cpp
#include
#include
#ifndef DATASTRUCT
#define DATASTRUCT
#include "datastruct.h"
#endif
#include "ListOper.h"
using namespace std;
bool CreateList(LinkList &L)
{
//TODO: 创建线性链表
Node *head;
head=(Node *)malloc(sizeof(Node));
if(head==NULL)
{
cout c=0;
head->e=0;
L=head;
return true;
}
Node *CreateNode(int e, int c)
{
//TODO: 创建结点
Node * pos;
pos=(Node *)malloc(sizeof(Node));
if(pos==NULL)
{
cout c=c;
pos->next=NULL;
return pos;
}

void FreeList(LinkList &L)
{
//TODO: 释放整个线性表所占用的内存空间
Node *pos;
Node *next;
pos=L;
while(pos!=NULL)
{
next=pos->next;
free(pos);
pos=next;
}
}
void SortList(LinkList &L)
{
bool flag=true; //是否需要排序标志
Node *head=L->next;
Node *pos;
Node *last;
Node *temp;
if(head->next==NULL)
{
return;
}
while(flag)
{
flag=true;
last=head;
pos=last->next;
if(last==NULL||last->next==NULL)
{
break;
}
while(last!=NULL && last->next!=NULL)
{
flag=false;
pos=last->next;
if(last->ee) //哈哈哈哈哈,HTML代码
{
SweepNextNode(last);
flag=true;
}
if(last->e==pos->e)
{
last->c+=pos->c;
DeleteNextNode(last);
flag=true;
/*last=last->next;
pos=last->next;*/
}
last=last->next;
}
}
}
void DeleteNextNode(Node *d)
{
Node *temp;
temp=d->next;
d->next=temp->next;
free(temp);
}
void SweepNextNode(Node *s)
//一点偷懒的办法,只交换值,不修改指针
{
int c,e;
c=s->c;e=s->e;
s->c=s->next->c;s->e=s->next->e;
s->next->c=c;s->next->e=e;
}
void OutPutList(LinkList &L)
{
Node *pos;
pos=L->next;
cout c>0)
{
cout c!=1)
{
cout c;
}
if(pos->e!=0)
{
cout next;
}
cout