主页 > 程序语言 > 栈的基本操作的C语言程序

栈的基本操作的C语言程序

2023-10-24 22:26来源:m.sf1369.com作者:宇宇

一、栈的基本操作的C语言程序

#include <stdio.h>

#include <stdlib.h>

#define MAX 1024 ///栈使用数组模拟,MAX是最大元素个数

typedef int DataType; ///数据域使用整形

typedef struct _stack

{

DataType data[MAX]; ///存放数据

int top; ///栈顶指针

}stack;

///初始化

int initStack(stack (*s))

{

return emptyStack(s);

}

///数据压栈,成功返回1,失败返回0

int push(stack (*s), DataType d)

{

if ((*s).top >= MAX - 1) //栈已满

{

printf(栈已满,不能压栈\n);

return 0;

}

//数据压栈

(*s).top++;

(*s).data[(*s).top] = d;

return 1;

}

///数据出栈,成功返回1,d指向的区域存储弹出的数据,失败返回0

int pop(stack (*s), DataType *d)

{

if ((*s).top <= -1)

{

printf(栈为空,不能出栈\n);

return 0;

}

//出栈

*d = (*s).data[(*s).top];

(*s).top--;

return 1;

}

///清空栈

int emptyStack(stack (*s))

{

(*s).top = -1;

return 1;

}

int main(int argc, char** argv)

{

stack s;

int i, d;

initStack(&s);

//压栈

for (i = 0; i < 1025; i++)

{

push(&s, i);

}

//清空

emptyStack(&s);

for (i = 0; i < 10; i++)

{

push(&s, i);

}

//出栈

for (i = 0; i < 11; i++)

{

pop(&s, &d);

printf(%d\n, d);

}

return 0;

}

二、msn live space怎么从英文变成中文

一个叫MSN的聊天软件,搞的想生活在空间一样!!

三、什么是mel语言?

mel语言是maya自己内部的一套编程语言,mel是maya的灵魂,是maya执行命令的语言。稍有编程基础的话,可以很容易掌握它。我们可以看到除了maya的插件(maya内部很多组件也都是以插件形式存在的)以外,所有的操作都可以在script editor窗口中有相应的mel语言与之对应。例如:创建一个常规的polygon球体,打开windows-->General Editors-->Script Editor,可以看到:polySphere -r 1 -sx 20 -sy 20 -ax 0 1 0 -tx 2 -ch 1;;这句话的意思是创建一个polygon球体(polySphere),其半径为1(-r 1),x、y轴向的分段皆为20(-sx 20 -sy 20),轴向为Y轴向上(-ax 0 1 0),显示方式为有锯齿贴图(-tx 2),并带有历史纪录(-ch 1)。参见help中的polySphere词条。

*表达式的作用:

1,使属性与时间建立关系,来产生动画效果。

2,建立属性与属性的联系,来达到用一个属性控制另一个属性的目的。

四、space application是什么意思

space application

空间应用

双语例句

1. Second chapter emphatically introduces the glass in modern architecture space application.

第二部分着重介绍玻璃在现代建筑空间中的应用.

2. The user - space application decides whether the event requires any action on its part.

用户空间的应用程序来决定是否要在事件上对自己的设备做出响应.

3. Because of its low efficiency and big dimension plate - fin heat exchanger is unsuitable in space application.

但对于空间换热器来说,不光其效率过低,尺寸也过大,因此需要考虑其它更为紧凑高效的换热器型式.

4. In this model, the user - space application performs a system call that results in the application blocking.

在这个模型中, 用户空间的应用程序执行一个系统调用,这会导致应用程序阻塞.

5. If the cargo space must be reserved, please send us the necessary application forms.

如果要预订货舱, 请将订舱表寄给我们.

相关推荐

哪些编程语言是函数式的

程序语言 2024-01-14

VB编程的函数详解

程序语言 2024-01-02

c语言扑克牌问题

程序语言 2023-12-28

iphone语言与地区有什么用?

程序语言 2023-12-19

C语言程序,怎么使用,

程序语言 2023-12-17

把word嵌入到C#程序中

程序语言 2023-11-26

HTML是不是编程语言?

程序语言 2023-11-17