该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
#include
#include
#include
int list[25];int i,n,a,sum=0,k,l;
int eleminsert;
/*------------------创建函数--------------*/
void initlist()
{
printf("Please input the total of the elems:");
scanf("%d",&n);
if(n>25||n<1) {printf("ERROE!");return;}
printf("Please input the elems:...\n");
for(i=0;i
{scanf("%d",&list[i]);
}
return;
}
/*------------------打印函数--------------*/
void Print(int list[],int n)
{
int j;
for(j=0;j
printf("%d\t",list[j]);
printf("\n");
return;
}
/*------------------查找函数------------*/
int Search(int list[],int n,int m)
{
if(m<1||m>n){printf("ERROR!\n"); return ;}
else printf("The elem is %d at %d place\n",list[m-1],m);
return;
}
/*----------------插入函数------------*/
void Insert(int list[],int n,int m,int elem)
{
}
/*---------------删除函数-----------*/
void Delete(int list[],int n,int m)
{
}
/*-------------求和函数------------*/
void Sum(int list[],int n,int sum)
{
int j;
for(j=0;j
{sum=sum+list[j];}
printf("The sum is :%d",sum);
return;
}
void menu()
{
int j;
/*------------菜单函数------------*/
menulab:
printf("********************** MENU ******************\n\n");
printf("Create a new int list :...................press 1\n\n");
printf("Print the whole list :....................press 2\n\n");
printf("Search by order :........................press 3\n\n");
printf("Insert the elem in the place i:...........press 4\n\n");
printf("Delete the elem by order :................press 5\n\n");
printf("Sum all elem in the list :................press 6\n\n");
printf("exit the programe :.......................press 0\n\n");
printf("********************** END *******************\n\n");
printf("Please choose the number from (0~6).....");
checklabel: scanf("%1d",&j);getchar();
if(j<0||j>6)
{printf("Error! Please choose again......");
goto checklabel;
}
printf("\n\tYou choose the number %d\n ",j);
printf("\n\tPress any key to continue.....");
getchar();
clrscr(); /*clear screen*/
switch(j)
{
case 1:/*创建任意整数线性表*/
initlist();
clrscr(); /*clear screen*/
goto menulab;
case 2: /*打印(遍历)该线性表*/
printf("The original list is:");
_______________
printf("Press any key to continue.....");
getchar();
clrscr(); /*clear screen*/
goto menulab;
case 3:/*在线性表中查找第i个元素,并返回其值*/
printf("Input which LNode you want to Search(Input number):");