小弟初来乍到,编程菜鸟,求各位帮忙看看程序
想在线性表中插入一元素
#define MAXSIZE 1000 main() { int list[1000],result,i,n,x; printf("\nInput the number:\n"); scanf("%d",&n); printf("\nInput the array!\n"); for (i=0;i<n;i++) scanf("%d",&list[i]); printf("\ninsert the number you want to insert:\n"); scanf("%d",&x); result=sq_insert(list,n,x); {case 0: printf("\ninsert successfully!"); for(i=0;i<n;i++) printf("\n%d\n",list[i]); break; case 1: printf("error"); break; } } int sq_insert(list,*p,int i,q) int list[1000]; int j; if(i<0||i>p+1) { printf("Error"); return 1;} if(j=*p>=n-1) {printf("overflow!") return 1;} for(j<*p;j>=i;j--) list[j+1]=list[j]; list[i]=x; (*p)++; return 0; }