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

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

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

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

EG1hao
网课代修代上,cs代写代考
C语言代做
您的位置: 主页 > 编程案例 > C语言代做 >
代做C语言:Programming Exercise 4 Stack Implementation - C语言代做
发布时间:2021-07-25 14:47:33浏览次数:
1.Purpose The purpose of this exercise is to make the students familiar with: (1)the array based implementation of stack;(2)the linked list based implementation of stack;(3)the basic application of stack;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 Array Based Implementation of StackExercise 4.1 (40 points) Create a stack with some data elements, and finish such operations as initialization, Push, Pop, etc.All operations should be implemented as independent functions, which can be called by the main function.(1)Create a stack by entering some positive integer data elements, and end the process by entering -1, and output all the elements;(2)Get the length of the stack;(3)Delete a data element from the stack, and output the data value.3.2 Linked List Based Implementation of StackExercise 4.2 (30 points) Create a stack with some data elements, and finish such operations as initialization, Push, Pop, etc.All operations should be implemented as independent functions, which can be called by the main function.(1)data elements, and end the process by entering -1, and output all the elements;(2)Get the length of the stack(3)Add a new data element into the stack;(4)Delete a data element from the stack, and output the data value3.3Application of stackExercise 4.3 (10points)Write an algorithm to convert a non-negative decimal number to its equivalent octal numberExercise 4.4(10 points)Use letter I and O to represent PUSH and POP operation respectively. The initial state and end state of stack should both beempty, a sequence of PUSH and POP operation is represented by the sequence composed of I and O only. Such asequence is legal only when it is operable, otherwise it is illegal. Write an algorithm to judge whether the following sequences are legal or not. S1:IOOIIOIOOS2:IOOIOIIOS3:II I O I O I OS4:I I I O O I O OExercise 4.5 (10 points)Write an program to receive a character string from the keyboard(the maximum length is 100), and test whether the brackets (),[],{}in the string are matching.4. Reference CodeExercise 4.1#include stdio.h #include stdlib.h #include malloc.h #defineERROR0#defineOK1#defineTRUE1#defineFALSE0typedefintSElemType;typedefintStatus;//definitionofarraybasedstack#defineSTACK_INIT_SIZE100//Initialsizeformemoryallocation#defineSTACKINCREMENT10//incrementalsizetypedefstruct{SElemType*base;//basepointerSElemType*top;//toppointerintstacksize;//currentsize}SqStack;//==========================================//initializationofarray-basedstack//===========================================StatusInitStack(SqStack S){S.base=(SElemType*)malloc(STACK_INIT_SIZE*sizeof(SElemType));if(!S.base)returnERROR;S.top=S.base;S.stacksize=STACK_INIT_SIZE;returnOK;//========================================//Testemptystack//========================================StatusStackEmpty(SqStackS){addsomecodeshere//===============================================//Getthelengthofastack//==============================================intStackLength(SqStackS){addsomecodeshere//=====================================//Gettopitemofastack//====================================StatusGetTop(SqStackS,SElemType e){addsomecodeshere}//===================================================//Deleteanitemfromthestack//====================================================StatusPop(SqStack S,SElemType e){addsomecodeshere}//======================================//Insertanitemintothestack//=======================================StatusPush(SqStack S,SElemTypee){if(S.top-S.base =S.stacksize){//stackisfull,increasethesizeS.base=(SElemType*)realloc(S.base,(S.stacksize+STACKINCREMENT)*sizeof(SElemType));if(!S.base)returnERROR;S.top=S.base+S.stacksize;S.stacksize+=STACKINCREMENT;}addsomecodesherereturnOK;//======================================//Printtheelementsinastack//=======================================voidPrintStack(SqStackS){SElemType*p;printf(“ thedataelementinthestackis ”)for(p=S.base;p S.top;p++)printf(“%d ”,*p);intmain(){SqStackS1;inte;intlen;inttmpPos;InitStack(S1);printf(“pleaseenterthedataitem ”);scanf(“%d”, e)while(e!=-1)Push(S1,e);scanf(“%d”, e)PrintStack(S1);len=StackLength(S1);printf(“thelengthofthestackis%d ”,len);Pop(S1,e);printf(“thetopelementis%d ”,e);returnOK;}Exercise 4.2#include stdio.h #include stdlib.h #include malloc.h #defineERROR0#defineOK1#defineTRUE1#defineFALSE0typedefintSElemType;typedefintStatus;typedefstructL_node{SElemTypedata;//datafieldstructL_node*next;//pointerfield}LNode,*LinkList;typedefstruct{LinkListHead;//headpointerintlength;//length}LinkStack;//==========================================//initializationoflinkedlistbasedstack//===========================================StatusInitStack(LinkStack S){S.Head=(LinkList)malloc(sizeof(LNode));if(!S.Head)returnERROR;S.Head=NULL;returnOK;//========================================//Testemptystack//========================================StatusStackEmpty(LinkStackS){addsomecodeshere//===============================================//Getthelengthofastack//==============================================intStackLength(LinkStackS){addsomecodeshere//=====================================//Gettopitemofastack//====================================StatusGetTop(LinkStackS,SElemType e){if(S.Head- next==NULL)returnERROR;addsomecodeshere//===================================================//Deleteanitemfromthestack//====================================================StatusPop(LinkStack S,SElemType e){addsomecodeshere//======================================//Insertanitemintothestack//=======================================StatusPush(LinkStack S,SElemTypee){addsomecodeshere//======================================//Printtheelementsinastack//=======================================voidPrintStack(LinkStackS){LinkListp;p=L- next;printf(“ Theelementsofthestackare:”);while(p){printf(“%d,”,p- data);p=p- next;printf(“ ”);intmain(){LinkStackS1;inte;intlen;InitStack(S1);printf(“pleaseenterthedataitem ”);scanf(“%d”, e)while(e!=-1)Push(S1,e);scanf(“%d”, e)PrintStack(S1);len=StackLength(S1);printf(“thelengthofthestackis%d ”,len);Pop(S1,e);printf(“thetopelementis%d ”,e);returnOK;}Exercise 4.3Note: reusable codes in Exercise 4.1 are not repeated here.voidConversion(){//foranon-negativedecimalnumber,printoutitsequivalentoctalnumberSqStackS;intN;inte;InitStack(S);scanf( %d ,N);addsomecodesherewhile(!StackEmpty(S)){Pop(S,e);printf( %d ,e);}intmain()Conversion();Exercise4.4Note:reusablecodesinExercise4.1arenotrepeatedhere.typedefcharSElemType;StatusJudgeLegal(chars[])SqStackS;charc;chare;InitStack(S);for(i=0,c=s[i];c!=’’;++i,c=s[i])addsomecodeshereif(StackEmpty(S)returnTURE;elsereturnFALSE;charS1[]=“IOOIIOIOO”;charS2[]=“IOOIOIIO”;charS3[]=”IIIOIOIO”;charS4[]=”IIIOOIOO”;intmain()if(JudgeLegal(S1)==TRUE)printf(“thestring%sislegal ”,S1);elseprintf(“thestring%sisillegal ”,S1);addsomecodeshereExercise4.5Note:reusablecodesinExercise4.1arenotrepeatedhere.typedefcharSElemType;StatusBracketsMatching(chars[])SqStackS;charc;chare;InitStack(S);for(i=0,c=s[i];c!=’’;++i,c=s[i])if(c==’(’||c==’[’||c==’{’)Push(S,c);elseif(c==’)’||c==’]’||c==’}’)addsomecodeshereintmain()charc;chars[100];intlen=0;c=getchar();while(c!=’#’)//‘#’meanstheendofstrings[len++]=c;c=getchar();s[len]=’’;if(BracketsMatching(s)==TRUE)printf(“thebracketsinthestringarematching”);printf(“thebracketsinthestringarenotmatching”);}代写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++、数据结构代写、代写数据结构、数据结构代做、代做数据结构等留学生编程作业代写服务。