东北大学计算机软件基础实验报告,东北大学软件技术基础实验报告.doc

文档介绍:

实验一代码:#include"iostream"#include//定义一个线性表constintnMaxSize=15;  //最大值intnLen=0;        //表中元素个数intnLinearList[nMaxSize];//定义操作voidLSort();voidLOut();voidLInsert(intn);voidLDelete(intn);voidmain(){//输入数据并放入线性表中printf("Pleaseinputdata\n");  //std::cout<>nIn;nLinearList[i]=nIn;nLen++;}LSort();  //排序线性表LOut();    //输出结果printf("Pleaseinputadatatoinsert\n");scanf("%d",&nIn);LInsert(nIn);  //输入一个数字,并插入到线性表中LOut();LSort();printf("sorted:\n");LOut();  while(1){printf("Pleaseinputanumberofdatatodelete\n");scanf("%d",&nIn);if(nIn>nLen)printf("numbermustlessthan%d\n",nLen);elsebreak;}LDelete(nIn);  //输入一个数字,并从线性表中删除LOut();  charchTmp;printf("Pleaseinputachartofinishthisprogram.");chTmp=getch();}voidLSort()      //冒泡排序,由大到小{inti,j,temp;for(j=0;jnLen)printf("placenumbermustlessthan%d\n",nLen);elsebreak;}for(i=nLen;i>=j;--i)nLinearList[i]=nLinearList[i-1];nLinearList[j-1]=k;nLen++;}voidLDelete(intm){inti;for(i=m;i<=nLen;++i)nLinearList[i-1]=nLinearList[i];nLen--;}实验二代码:#include#include#include#includeconstintMAX_LEN=10;    //字符串的长度constintMAX_SIZE=30;  //栈或队的最大元素个数//定义一个队列的结构structQUEUE{intnMaxSize;  //最大值intnCount;    //个数intnFront;    //头intnRear;    //尾charszQueue[MAX_SIZE][MAX_LEN];};//定义一个栈的结构structSTACK{intnMaxSize;  //最大值intnTop;    //栈顶charszStack[MAX_SIZE][MAX_LEN];};//队列的操作voidInitQueue(QUEUE*q,intnMaxSize){q->nMaxSize=nMaxSize;q->nCount=0;q->nFront=0;q->nRear=0;q->szQueue[MAX_SIZE][MAX_LEN]=0;}voidInQueue(QUEUE*q,char*pItem){if(q->nCount==q->nMaxSize){printf("Queueisfull!\n");return;}strcpy(q->szQueue[q->nRear],pItem);if(q->nRear

内容来自淘豆网www.taodocs.com转载请标明出处.

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值