




如果您无法下载资料,请参考说明:
1、部分资料下载需要金币,请确保您的账户上有足够的金币
2、已购买过的文档,再次下载不重复扣费
3、资料包下载后请先用软件解压,在使用对应软件打开
中国地质大学数据结构实习报告 第一篇:中国地质大学数据结构实习报告PracticeReportforDataStructuresandAlgorithmAnalysisDataStructuresCourseReportCandidate:StudentNumber:Major:CommunicationEngineeringSupervisor:WurangzhongChinaUniversityofGeosciences(Wuhan)Wuhan,Hubei430074,P.R.ChinaMay18,2013ChinaUniversityofGeosciences,FacultyofMechanicsandElectronicInformation删除程序代码voidDeletekTh(intposition,pNodeL){pNodeTmp=L,TmpPre=NULL;inti=0;for(i=0;i{if(Tmp->next!=NULL){TmpPre=Tmp;Tmp=Tmp->next;}elseif(Tmp->next==NULL&&i{printf(“TheDeletionpositionisinvalid!n”);return;}}TmpPre->next=Tmp->next;free(Tmp);}这是程序主函数,以此来完成以上子函数的功能#include#include#include“lianbiao.h”intmain(){inti,x,position;pNodem;pNodeLinkLists;{printf(“输入元素来建立链表,0为结束输入的标志”);LinkLists=CreateLinkLists();printf(“链表为:”);PrintLists(LinkLists);}printf(“选择你需要的操作,输入序号:n”);printf(“1.建立一个链表n”);printf(“2.输出链表n”);}2.数组实现线性表用数组实现的功能和用链表表示的相同部分子函数如下//初始化顺序表:给出初始化长度intinitialArray(arrayListarrLst,intlen){arrLst->length=0;arrLst->size=len;arrLst->Array=(ElemType*)malloc(len*sizeof(ElemType));if(arrlst->Array==NULL)return0;elsereturn1;}//删除顺序表voiddeleteArray(arrayListarrLst){arrLst->length=0;arrLst->size=0;free(arrLst->Array);arrLst->Array=NULL;}//清空顺序表voidclearArray(arrayListarrLst){}printf(“n”);}//判断某个元素的位置intlocateElem(arrayListarrLst,ElemTypee){inti;for(i=0;i{if(e==arrLst->Array[i])returni;}return-1;}堆栈主要是实现元素的进栈、出栈、判断栈中元素个数堆栈的源函数#include#include#include“duizhan.h”STACKCreatStack(){STACKS;S=(STACK)malloc(sizeof(structStack));if(S==NULL){printf(“无法建立堆栈!”);return0;}S->top=-1;returnS;}intIsFull(STACKS){return(S->top==MAX-1);}intIsEmpty(STACKS){intStackLen(STACKS){if(!IsEmpty(S))returnS->top;elsereturn0;}堆栈的主函数#include#include#include“duizhan.h”voidmain(){STACKliliS;liliS=CreatStack();Push(1,liliS);Push(2,liliS);Push(3,liliS);Pop(liliS);Pop(liliS);DisposeStack(liliS);}设置断点可以看到栈中的元素主函数voidmain(){STRING*Str,*Pat;intposition=0;Str=(STRING*)malloc(sizeof(STRING));Pat=(STRING*)malloc(sizeof(STRING));charS_str[20]=“ababcabcacbab”;charP_str[20]=“abcac”;Str->p_str=S_str;S

雨巷****轶丽
实名认证
内容提供者


最近下载