自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(0)
  • 资源 (4)
  • 问答 (1)
  • 收藏
  • 关注

空空如也

表达式求值(栈的应用)

#define STACK_INIT_SIZE 100 #define STACKINCREMENT 10 #include<iostream> #include<stdlib.h> using namespace std; typedef double SElemType; ///////////////////////////////////////////////////////////////////////////////// /*以下为栈的操作*/ typedef struct SqStack //栈的顺序存储结构 { SElemType *base; SElemType *top; int stacksize; }SqStack; void InitStack (SqStack &S)//构造一个空栈 { S.base=(SElemType *)malloc(STACK_INIT_SIZE*sizeof(SElemType));//分配储存空间 if(!S.base) exit (-1); //空间分配失败 S.top=S.base; S.stacksize=STACK_INIT_SIZE; //空间初始分配 }//InitStack bool GetTop (SqStack S,SElemType &e) { //若栈不空,则用e返回S的栈顶元素,并返回true;否则返回false if(S.top==S.base) return false; e=*(S.top-1); return true; }//GetTop

2011-05-08

双向栈的基本操作和实现

/************************************************** 实验二 双向栈实现 1、 定义栈的存储结构。 2、 编写程序实现双向栈的基本操作:1)初始化;2)判断栈是否为空;3)判断栈是否已满;4)入栈;5)出栈;6)清空栈;7)取栈顶元素。 3、 所写源代码编程风格良好,有详细注释。 4、 程序运行界面良好,使用菜单实现每个基本操作。 ****************************************************/ #include #include #include #define NULL 0 #define MAX 20 #define TRUE 1 #define FALSE 0 typedef struct tagstack{ /*定义一个双向栈*/ int * pStack;/*栈底 同base指针*/ int lefttop;/*左栈栈顶*/ int righttop;/*右栈栈顶*/ }STACK;

2011-05-08

线性表的基本操作和实现

#include<stdio.h> #include<stdlib.h> #include<assert.h> #include<conio.h> #define MAXSIZE 100 typedef struct { int data[MAXSIZE]; int length; }Seqlist; void SeqlistInit(Seqlist *&L) // 线性表的初始化 { L=(Seqlist *)malloc(sizeof(Seqlist)); L->length=0; } void Creatlist(Seqlist *&L,int a[],int n) //建立顺序表 { int i; for(i=0;i<n;i++) L->data[i]=a[i]; L->length=n; }

2011-05-08

稀疏矩阵(十字链表操作)

数据结构稀疏矩阵实验课程设计 /********function definition********/ int init_matrix(crosslist &one) {//initialization one.row_size=0; one.colum_size=0; one.non_zero_amount=0; one.rhead=NULL; one.chead=NULL; return OK; }//init_matrix int creat_matrix(crosslist &one) {//assignment int i;//as count in the loop element news,temp; /*input row size ,colum size and non zero amount*/ printf("Input the row size of the matrix:"); scanf("%d",&one.row_size); printf("Input the colum size of the matrix:"); scanf("%d",&one.colum_size); printf("Input the non zero amount of the matrix:"); scanf("%d",&one.non_zero_amount); /*allocate memory and the first memory not use*/ one.rhead=(element*)malloc(sizeof(element)*(one.row_size+1)); assert(one.rhead!=NULL);//assert have space one.chead=(element*)malloc(sizeof(element)*(one.colum_size+1)); assert(one.chead!=NULL); /*set all the pointer to NULL*/ for(i=1;i<=one.row_size;i++) one.rhead[i]=NULL; for(i=1;i<=one.colum_size;i++) one.chead[i]=NULL; printf("/**************************************/\n"); /*assignment*/ for(i=1;irow); }while(news->row>one.row_size); do {//insure the colum script is valid printf("Input the script of the colum:"); scanf("%d",&news->colum);

2011-05-08

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除