EssayGhost Assignment代写,Essay代写,网课代修,Quiz代考

EssayGhost-Essay代写,作业代写,网课代修代上,cs代写代考

一站式网课代修,论文代写

高质量的Assignment代写、Paper代写、Report代写服务

EG1hao
网课代修代上,cs代写代考
C/C++代写
您的位置: 主页 > 编程案例 > C/C++代写 >
代写C++/C:CS代写之C语言Programming Exercise 3 Singly Linked List Implementary - C++代写
发布时间:2021-07-25 22:31:10浏览次数:
Programming Exercise 3 Singly Linked List Implementation and Application1.Purpose The purpose of this exercise is to make the students familiar with: (1)the implementation of basic operations of singly linked list;(2)the basic application of singly linked list;2.Grading Policy (1)The full mark is 100, which is equivalent to 5 points in the final score of this course.(2)The assessment is based on the correctness and quality of the code, the ability demonstrated in debugging and answering related questions raised by the lecturer and teaching assistants. (3)The exercises should be completed individually and independently.(4)Some reference codes are provided at the end of this document, only for the purpose of helping those students who really have difficulties in programing. It is allowed to use the reference codes. However, straight copy from the reference codes or with minor modification can only guarantee you to get a pass score. Therefore, the students are encouraged to write their own codes to get a higher score.3.Contents of Exercises3.1 Implementation of basic operations of singly linked list Exercise 3.1 (60 points) Create a singly linked list with some data elements, and finish such operations as initialization, insertion, deletion etc.All operations should be implemented as independent functions, which can be called by the main function.(1)Create a singly linked list with data elements of 21, 18, 30, 75, 42, 56, and output all the elements(2)Get the length of the list, and output the value;(3)Get the 3rd element of the list, and output the value;(4)Insert 67 into the list at positon 3,and then output all the elements in the list;(5)Delete the 2ndelement from the list, and then output all the elements in the list;(6)Search for 30 in the list. If found, report the position of the element;3.2 Application of singly linked listExercise 3.2(20 points)Based on the singly linked list created in step(1) of Exercise 3.1, complete following tasks:(1)Get the maximum data element in the list, and print the maximum data;(2)Test whether the list is in ascending order;Exercise 3.3 (20 points)Create a singly linked list with head node and with date elements as 10, 21,32,43,54, 65, 76, and complete following tasks:(1)Insert 35 into the list, and keep the list in ascending order;(2)Delete all the elements whose data value are between 22 and 574. Reference CodeExercise 3.1#include stdio.h #include stdlib.h #include malloc.h #defineERROR0#defineOK1#defineTRUE1#defineFALSE0typedefintElemType;typedefintStatus;//definitionofnodestructureofsinglylinkedlisttypedefstructL_node{ElemTypedata;//datafieldstructL_node*next;//pointerfield}LNode,*LinkedList;//==========================================//initializationofsinglylinkedlistLwithheadnode//===========================================StatusInitList_L(LinkList L)L=(LinkList)malloc(sizeof(LNode));//makeanodeif(!L)returnERROR;L- next=NULL;//emptylistreturnOK;//===========================================//CreateasinglylinkedlistLwithheadnode,andwithnelements//===========================================StatusCreateList_L(LinkList L,intn)LinkListp,q;inti;L=(LinkList)malloc(sizeof(LNode));//createanemptylistif(!L)returnERROR;L- next=NULL;q=L;for(i=0;i i++){p=(LinkList)malloc(sizeof(LNode));//makeanewnodeif(!p)returnERROR;scanf( p- data);//enterelementdatafromkeyboardaddsomecodeshere}p- next=NULL;returnOK;//=========================================//Getthelengthofasinglylinkedlistwithheadnode//=========================================intListLength_L(LinkListL){inti;LinkListp;p=L- next;//letppointtothefirstnodei=0;//iisacounterwhile(p){//traversethelisttocountthenodesaddsomecodeshere}returni;}//========================================//Gettheithelementofasinglylinkedlist//========================================StatusGetElem_L(LinkListL,inti,ElemType e){intj;LinkListp;p=L- next;//letppointtothefirstnodej=1;//jisacounterwhile(p (j i)){//movepuntilppointstotheithelementaddsomecodeshere//orpbecomesNULL}if(!p||j i)returnERROR;//theithelementdoesn’texiste=p- data;//getthedataoftheithelementreturnOK;}//===============================================//searchforanelementinasinglylinkedlistandreturnitsposition//==============================================intLocateElem_L(LinkListL,ElemTypee)intj;LinkListp;p=L- next;//ppointstothefirstnodej=1;//jisacounterwhile(p !(p- data!=e)){//movepp=p- next;++j;//untilppointstotheithelement}addsomecodeshere//=====================================//Insertelementeattheithpositionofasinglylinkedlist//====================================StatusListInsert_L(LinkList L,inti,ElemTypee)intj;LinkListp,s;p=L;while(p j i-1){p=p- next;++j;}//locatethe(i-1)thnodeif(!p||j i-1)returnERROR;//i 1ori listlengths=(LinkList)malloc(sizeof(LNode));//makeanewnodeaddsomecodesherereturnOK;//===================================================//Deletetheithelmentfrom//====================================================StatusListDelete_L(LinkList L,inti,ElemType e)intj;LinkListp;p=L;while(p- next j i-1){//locatetheithnode,//andppointstoitsprecursorp=p- next;++j;}if(!(p- next j i-1)returnERROR;//errorforthepositionfordeletionaddsomecodesherereturnOK;//======================================//Printtheelementsinalist//=======================================voidLinkedListPrint(LinkedListL){LinkListp;p=L- next;printf(“ Theelementsoflinkedlistis:”);while(p){printf(“%d,”,p- data);p=p- next;printf(“ ”);intmain(){inte;ElemTypee;LinkedListLA;intlen;inttmpPos;//Createasinglylinkedlistwithelementsof21,18,30,75,42,56CreateLinkedList(LA,6);LinkedListPrint(LA);//getthelengthlen=ListLength_L(LA);printf(“thelengthofthelistis%d ”,len);//getthe3rdelementGetElem_L(LA,3,e);printf(“the3rdelementis%d ”,e);//insert67intothelistatposition3ListInsert_L(LA,3,67);LinkedListPrint(LA);//deletethe2ndelementListDelete_L(LA,2);LinkedListPrint(LA);//Searchfor30intheliste=30;tmpPos=LocateElem_L(LA,e);printf(“thepositionofelement%dis%d”,e,tmpPos);returnOK;}Exercise 3.2Note: reusable codes in Exercise 3.1 are not repeated here.//=======================================//testwhetherasinglylinkedlistisinascendingorder//=======================================intIsAscendingOrder_L(LinkListL)LinkListp;p=L- next;while(p- next){addsomecodeshere.}returnTRUE;//=================================//Getthemaximumelementinasinglylinkedlist//================================StatusGetMaximum_L(LinkListL,ElemType e)LinkListp;inttempMax;p=L- next;if(!p)returnERROR;tempMax=p- data;while(p){addsomecodesheree=tempMax;returnOK;intmain(){inte1;ElemTypee;LinkedListLA;intlen;intretVal;//Createasinglylinkedlistwithelementsof21,18,30,75,42,56CreateLinkedList(LA,6);LinkedListPrint(LA);//Getthemaximumdataofthelist,andprintthedata;GetMaximum_L(LA,e);printf(“themaximumdatais%d ”,e);//testwhetherlistisinascendingorderretVal=IsAscendingOrder_L(LA);if(retVal)printf(“thelistisinascendingorder”);printf(“thelistisnotinascendingorder”);returnOK;}Exercise3.3Note:reusablecodesinExercise3.1arenotrepeatedhere.//========================================//InsertelementintoanascendinglyorderedlistL,andkeepLinascendingorder//========================================StatusOrderedListInsert(LinkListL,ElemTpyee)LinkListp;p=L- next;while(p){addsomecodeshere//findtheproperpositionwhereelementeisinserteds=(LinkList)malloc(LNode);//makeanewnodeif(!s)returnERROR;s- data=e;addsomecodeshere//insertthenewnodeintothelinkedlistreturnOK;//============================================================//Fromanascendinglyorderedlinkedlist,deletealltheelementsrangedbetweenaandb,//wherea b//============================================================StatusOrderedListDelete(LinkList L,inta,intb)LinkListp;p=L- next;while(p (p- data a)){p=p- next;while((p- next) (p- next- data b){addsomecodesherereturnOK;intmain(){LinkedListLA;//Createasinglylinkedlistwithbydateelementsas21,18,30,75,42,56CreateLinkedList(LA,6);LinkedListPrint(LA);//insert35intothelist;OrderedListInsert(LA,35);LinkedListPrint(LA);//deletealltheelementsrangedbetween22and57OrderedListDelete(LA,22,57);LinkedListPrint(LA);}代写CS Finance|建模|代码|系统|报告|考试编程类:C++,JAVA ,数据库,WEB,Linux,Nodejs,JSP,Html,Prolog,Python,Haskell,hadoop算法,系统 机器学习金融类:统计,计量,风险投资,金融工程,R语言,Python语言,Matlab,建立模型,数据分析,数据处理服务类:Lab/Assignment/Project/Course/Qzui/Midterm/Final/Exam/Test帮助代写代考辅导天才写手,代写CS,代写finance,代写statistics,考试助攻E-mail:[email protected]微信:BadGeniuscs 工作时间:无休息工作日-早上8点到凌晨3点如果您用的手机请先保存二维码到手机里面,识别图中二维码。如果用电脑,直接掏出手机果断扫描。

所有的编程代写范围:essayghost为美国、加拿大、英国、澳洲的留学生提供C语言代写、代写C语言、C语言代做、代做C语言、数据库代写、代写数据库、数据库代做、代做数据库、Web作业代写、代写Web作业、Web作业代做、代做Web作业、Java代写、代写Java、Java代做、代做Java、Python代写、代写Python、Python代做、代做Python、C/C++代写、代写C/C++、C/C++代做、代做C/C++、数据结构代写、代写数据结构、数据结构代做、代做数据结构等留学生编程作业代写服务。