爱问知识人 爱问教育 医院库

试用C语言编程

首页

试用C语言编程

1.构造一个空线性表,算法见附件.
2.在线性表中插入元素,算法见附件.
3.销毁此线性表.

1.构造一个空线性表……
提交回答
好评回答
  • 2008-03-21 13:35:17
      //顺序表的储存结构及相关运算// ypedefstruct{chardata[32];intlength;}SqList;voidCreateList(SqList*&L,chara[],intn)//建立{inti;for(i=0;idata[i]=a[i];L->length=n;}voidInitList(SqList*&L)//初始化{L=newSqList;L->length=0;}voidDestroyList(SqList*&L)//摧毁{delete(L);}intListEmpty(SqList*L)//测空{return(L->length==0);}intListLength(SqList*L)//求长{return(L->length);}voidDispList(SqList*L)//输出{inti;if(ListEmpty(L))return;for(i=0;ilength;i++)coutdata[i]L->length)return0;e=L->data[i-1];return1;}intLocateElem(SqList*L,chare)//查找e{inti;for(i=0;ilength&&L->data[i]!=e;i++){}if(i>=L->length)return0;elsereturni+1;}intListInsert(SqList*&L,inti,chare)//插入{intj;if(iL->length+1)return0;i--;for(j=L->length;j>i;j--)L->data[j]=L->data[j-1];L->data[i]=e;L->length++;return1;}intListDelete(SqList*&L,inti,char&e)//删除数据{intj;if(iL->length)return0;i--;e=L->data[i];for(j=i;jlength-1;j++)L->data[j]=L->data[j+1];L->length--;return1;}//stdafx。
      h:includefileforstandardsystemincludefiles,//orprojectspecificincludefilesthatareusedfrequently,but//arechangedinfrequently//#pragmaonce#defineWIN32_LEAN_AND_MEAN//Excluderarely-usedstufffromWindowsheaders#include#include#include#includeusingnamespacestd;// :Definestheentrypointfortheconsoleapplication。
      //题目太长了--b……,总之大概这么用吧。#include"stdafx。h"#include"SqList。h"int_tmain(intargc,_TCHAR*argv[]){SqList*L;chare;InitList(L);ListInsert(L,1,'a');ListInsert(L,2,'b');ListInsert(L,3,'c');ListInsert(L,4,'d');ListInsert(L,5,'e');DispList(L);cout<  "<  顺序表的*/。

    烈***

    2008-03-21 13:35:17

类似问题

换一换

相关推荐

正在加载...
最新问答 推荐信息 热门专题 热点推荐
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200

热点检索

  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 177-196
返回
顶部
帮助 意见
反馈

确定举报此问题

举报原因(必选):