#include<stdio.h>
#include<stdlib.h>
#define NN 20
int q=0; /*the number of the a[] */
void create(int a[]) /* create the a[] and get the number of the yuansu*/
{
?int re=1,mo;char op;
?? for(mo=0;mo<NN&&re;mo++)
?? {
?? flushall();
?? printf("the%dnumberis: ",mo);
?? scanf("%d",&a[mo]); q++;flushall();
?? printf("end the things? y/n");
?? scanf("%c",&op);
? if(op=='y'||op=='Y')
?{ re=0;}
?? }
}
/*display*/
void display(int a[])
{
int m;
for(m=0;m<q;m++)
printf("the%dmnumberis%d? ",m,a[m]);
}
/*insert*/
int insert(int a[])
{
?int to,here,left,next,po;
?printf("where you want insert and the number want insert\nthe number is: ?");
?scanf("%d%d",&to,&po);
?if(q==NN||to>NN)
?{
?? printf("can't insert !");return 0;
?}
?? for(here=to;here<q;here++)
? {
??? left=a[here+1];
??? a[here+1]=a[to];
??? a[to]=left;
? }
? a[to]=po;q++;
}
/*delete*/
void dele(int a[])
{
int g,qp,who,er;
char yi;
printf("the number you want delete?the first or .....");
flushall();
scanf("%d",&g);
printf("you sure make a null number in here? y/n"); /* yes/no create a null number */
flushall();
scanf("%c",&yi);
if(yi=='n'||yi=='N')
{
? printf("enter a number to fill it!");
??? flushall();
??? scanf("%d",&qp);
??? a[g]=qp;
}
else
?{
?? for(who=g;who<q;who++)
?? {
?er=a[who+1];
?a[who+1]=a[g];
?a[g]=er;
?? }
?? q--;/* the all number cut one*/
?}
}
/** find and got it? */
int getme(int a[])
{int re,num,me;
printf("the number of you want get is :\n");
scanf("%d",&re);
for(num=0;num<q;num++)
{if(a[num]==re)
me=num;
}
printf("have your number is %d=%d\n",a[me],me);
return me;
}
void menu()
{
printf("**********************************************\n");
printf("??????? 1=create.\n");
printf("??????? 2=display \n");
printf("??????? 3=insert\n");
printf("??????? 4=delete \n");
printf("??????? 5=find\n");
printf("??????? 6=out \n");
printf("***********************************************\n");
}
main()
{ int qa[NN];
? int w=1,m;
? while(w)
?{ menu();
?? printf("give me a number :");
?? scanf("%d",&m);
?? switch(m)
?? {
? case 1:
? create(qa);break;
? case '2':
?? display(qa);break;
?? case '3':
?? insert(qa);break;
?? case '4':
?? dele(qa);break;
?? case '5':
?? getme(qa);break;
?? case '6':
?? w=0;break;
?? default:
?? menu();
?? printf(" \n");break;
?? }
}??? }