《软件技术基础教学课件》软件技术基础程序汇总

《软件技术基础教学课件》软件技术基础程序汇总

ID:47843466

大小:84.50 KB

页数:10页

时间:2019-11-24

《软件技术基础教学课件》软件技术基础程序汇总_第1页
《软件技术基础教学课件》软件技术基础程序汇总_第2页
《软件技术基础教学课件》软件技术基础程序汇总_第3页
《软件技术基础教学课件》软件技术基础程序汇总_第4页
《软件技术基础教学课件》软件技术基础程序汇总_第5页
资源描述:

《《软件技术基础教学课件》软件技术基础程序汇总》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库

1、Stack#inelude^defineMAXSIZE5structstack{intstk[MAXSIZE];inttop;};typedefstructstackSTACK;STACKs;voidpush(void);intpop(void);voiddisplay(void);voidmain(){intchoice;intoption=1;s.top二T;printf("STACKOPERATION"");while(option)printf(—————————————printf(”1—>PUSHE);print

2、fC2—>POPr);printfC3—>DISPLAYW);printf(”4—>EXITzz);printf(-r);printf(,zEnteryourchoicer)〃);scanf("%d:&choice)switchI(choice)icase1:push();break;case2:pop();break;case3:display();break;case4:return;}1tocontinuerT);fflush(stdin);printf("Doyouwtmttocontir)ue(Type0or1)?0to

3、quitandscanf(〃%d〃,&option);}}/*Functiontoaddanelementtothestack*/voidpush0intnum;if(s.top=(MAXSIZE-1))printf("StackisFull'rT);return;)else{printf("Entertheelernenttobepushed");scanf&nuni);S・top=S・top+1;s・stk[s・top]=num;}return;)/*Functiontodeleteanelementfromthestack*/int

4、pop0{intnum;if(s.top==-1){printf("StackisEmpty");return(s・top);}else{num=s.stk[s・top];printf("popedelementis=s・stk[s・lop]);s・top=s・top-1;}return(num);}/*Functiontodisplaythestatusofthestack*/voiddisplay(){inti;if(s・top—-1){printf("Stackisempty'n");return;}else{printf("T

5、hestatusofthestackis");for(i=s.top;i>=0;i--){printf("%d",s.stk[i]);}}printf("");remove30*/Link/*makelistof10203040500(stopwhenis0isenter),thenenter^include^include^includestructnode{intdata;structnode*next;};structnode*head;voidNodelnit(){s

6、tructnode*ppre,*qnew;intval;head=(structnode*)malloc(sizeof(structnode));ppre=head;for(:;)/*forverloop*/{scanf&val);if(val!=0){qncw=(sti^uctnode*)malloc(sizeof(structnode));qnew->data=val;ppre->next=qnew;/*head->ne=q*/ppre=qnew;}elsebretik;}ppre->ncxt=NULL;)voidprint0{struc

7、tnode*p;p-head->next;while(p){printf(v%d"、p->data);p=p->next;)printfC");)voidInsert(intval){structnode*ppre,*q,*cur;cur=(structnode*)malloc(sizeof(structnode));cur~>data=val;ppre二head;q二ppre-〉next;while(q!=MULL&&q->datanext=q;}v

8、oidDelete(intval){structnode*ppre,*cur;ppre二head;cur=ppre->next;while(cur){if(cur-

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。