局部变量顺序表--静态

#include

#define MAXLEN 50

typedef struct{

int elem[MAXLEN];

int last;

}Sqlisttp;

Sqlisttp insert(Sqlisttp V,int i,int b)

{

int j;

if(iV.last+1)

printf("ERROR!");

else if(V.last>=MAXLEN)

printf("OVERFLOW!");

else{

for(j=V.last-1;j>=i-1;j--)

V.elem[j+1]=V.elem[j];

V.elem[i-1]=b;

V.last++;

}

return V;

}

Sqlisttp delet(Sqlisttp V,int i)

{

int j;

if(iV.last) printf("ERROR!");

else{

for(j=i;j

V.elem[j-1]=V.elem[j];

V.last--;

}

return V;

}

void display(Sqlisttp V)

{

int j;

for(j=0;j

printf("%d ",V.elem[j]);

printf("\n");

}

main()

{

Sqlisttp V;

int i,b,j,value;

printf("please input the length:\n");

scanf("%d",&V.last);

printf("\n please input the value:\n");

for(j=0;j

{

scanf("%d",&value);

V.elem[j]=value;

}

printf("\n please input the insert position:");

scanf("%d",&i);

printf("\n please input insert node:");

scanf("%d",&b);

V=insert(V,i,b);

display(V);

printf("\n please input the delete position:");

scanf("%d",&i);

V=delet(V,i);

display(V);

}

#include

#define MAXLEN 50

typedef struct{

int elem[MAXLEN];

int last;

}Sqlisttp;

Sqlisttp insert(Sqlisttp V,int i,int b)

{

int j;

if(iV.last+1)

printf("ERROR!");

else if(V.last>=MAXLEN)

printf("OVERFLOW!");

else{

for(j=V.last-1;j>=i-1;j--)

V.elem[j+1]=V.elem[j];

V.elem[i-1]=b;

V.last++;

}

return V;

}

Sqlisttp delet(Sqlisttp V,int i)

{

int j;

if(iV.last) printf("ERROR!");

else{

for(j=i;j

V.elem[j-1]=V.elem[j];

V.last--;

}

return V;

}

void display(Sqlisttp V)

{

int j;

for(j=0;j

printf("%d ",V.elem[j]);

printf("\n");

}

main()

{

Sqlisttp V;

int i,b,j,value;

printf("please input the length:\n");

scanf("%d",&V.last);

printf("\n please input the value:\n");

for(j=0;j

{

scanf("%d",&value);

V.elem[j]=value;

}

printf("\n please input the insert position:");

scanf("%d",&i);

printf("\n please input insert node:");

scanf("%d",&b);

V=insert(V,i,b);

display(V);

printf("\n please input the delete position:");

scanf("%d",&i);

V=delet(V,i);

display(V);

}


相关内容

  • 对象与内存控制
  • 疯狂java读书笔记 java内存管理分为两部分:内存的分配与内存的回收 内存的分配:指创建java对象时,jvm为该对象在堆内存中所分配的内存空间. 内存的回收:指当该java对象失去引用,变成垃圾时,jvm的垃圾回收机制自动清理该对象,并回收该对象占用的内存. jvm的垃圾回收机制由一条后台线程 ...

  • 第五章 C 函数与程序结构
  • 第5章 C++函数与程序结构 本章要点: 1.掌握函数的概念.定义和调用方法. 2.理解C++函数参数传递的方法:值传递和引用传递.掌握函数参数值传递的3.过程,并能够灵活运用.后面的章节中,将进一步学习引用传递. 4.理解内联函数的概念.作用,会定义内联函数. 5.理解函数重载的概念.作用,能够熟 ...

  • JAVA的静态变量.静态方法.静态类
  • 静态变量和静态方法都属于静态对象,它与非静态对象的差别需要做个说明. (1)Java静态对象和非静态对象有什么区别? 比对如下: 静态对象                                                        非静态对象 拥有属性:               ...

  • 嵌入式面试技巧
  • 篇一:嵌入式系统面试的几个问题 嵌入 式程序员应知道的几个基本问题 文章来源: chinaunix 作者:nigel jo„ 更新时间:2007-2-3 [大 小] [加入收藏] c语言测试 是招聘嵌入式系统程序员过程中必须而且有效的方法.这些年,我既参加也组织了许多这种 测试,在这过程中我意识到这 ...

  • 1以下正确的函数定义是(
  • 学习情境五 一.选择题 函数与编译预处理习题解答 1.以下正确的函数定义是( ). A.double fun(int x, int y) B.double fun(int x,y) { z=x+y; return z ; } { int z; return z;} C.fun (x,y) D.dou ...

  • 华为软件研发岗笔试题总结
  • 操作系统(Operating System,简称OS)是管理计算机系统的全部硬件资源包括软件资源及数据资源:控制程序运行:改善人机界面:为其它应用软件提供支持等,使计算机系统所有资源最大限度地发挥作用,为用户提供方便的.有效的.友善的服务界面. 操作系统通常是最靠近硬件的一层系统软件,它把硬件裸机改 ...

  • 作用域和存储类型
  • 作用域和存储类型 在过程化程序设计中最基本的思想是将一个较大的.较复杂的问题,分解成若干个较小的.更为容易解决的子问题.把一个程序划分为若干个模块,每一个模块只完成一种任务,每一个种的每一个标识符都有其作用的范围,这样设计出来的程序层次分明.容易读懂.便于维护.并可被其他程序调用.本章介绍标识符的作 ...

  • 多处理机系统的死锁检测方法[综述]
  • 多处理机系统的死锁检测方法 摘要:在多处理机系统中,并发性得到了有效利用,但并发程序的不确定性使得死锁检测十分困难.针对现有的工作集中在使用分析.验证或测试的单一途径来检测死锁这一问题,本文通过分析现有工具的死锁检测能力,提出了综合使用工具的死锁检测方法.同时根据分析.验证和测试途径的不同特点,给出 ...

  • 成员变量与局部变量的区分
  • 1:成员变量和局部变量的区别(理解) (1)在类中的位置不同 成员变量:类中方法外 局部变量:方法定义中或者方法声明上 (2)在内存中的位置不同 成员变量:在堆中 局部变量:在栈中 (3)生命周期不同 成员变量:随着对象的创建而存在,随着对象的消失而消失 局部变量:随着方法的调用而存在,随着方法的调 ...