赶鸭子c语言解题思路,在线求一C语言解题

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

#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):");

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值