主题:谁帮我看一下这个,什么老是错啊!!
#include <stdio.h>
#include <stdlib.h>
#define LIST_INIT_SIZE 100
#define LISTINCREMENT 10
#define ERROR -1
#define OK 1
typedef struct{
int *elem;
int length;
int listsize;
}Sqlist;
Sqlist initlist(Sqlist L)
{
L.elem=(int*)malloc(LIST_INIT_SIZE*sizeof(int));
if(!L.elem)exit(printf("%s\n","Sqlist L can't be created because of OVERFLOW!"));
L.length=0;
L.listsize=LIST_INIT_SIZE;
return L;
}
sqlist interlist(Splist L, int i,int m)
{
int j,a;
if(i<1||i>L.length)
exit(printf("%s\n","ERROR:The delete position is illegal!"));
++L.length;
for(j=i-1;j<=L.length-1;j++)
L.elem[j]=L.elem[j-1];
return L;
}
Sqlist deletesqlist(Sqlist L,int i)
{
int j;
if(i<1||i>L.length)
exit(printf("%s\n","ERROR:The delete position is illegal!"));
for(j=i;j<=L.length-1;j++)
L.elem[j-1]=L.elem[j];
L.length--;
return L;
}
void main()
{
Sqlist L;
int i,k,e;
L=initlist(L);
for(i=1;i<=6;i++)
{
L.elem[i-1]=i;
L.length=L.length+1;
printf("%d\n",L.elem[i-1]);
}
printf("%s\n","below is the answer:");
prinf("\n s=");
if (s==0);
{
printf("\n k=");
scanf("%d",&k);
L=deletesqlist(L,k); }
else
printf("\n k= \n m=");
scanf("%d %d",&k &m);
L=interlist( L, k, m)
for(i=1;i<=L.length;i++)
printf("%d\n",L.elem[i-1]);
getch();
}
#include <stdlib.h>
#define LIST_INIT_SIZE 100
#define LISTINCREMENT 10
#define ERROR -1
#define OK 1
typedef struct{
int *elem;
int length;
int listsize;
}Sqlist;
Sqlist initlist(Sqlist L)
{
L.elem=(int*)malloc(LIST_INIT_SIZE*sizeof(int));
if(!L.elem)exit(printf("%s\n","Sqlist L can't be created because of OVERFLOW!"));
L.length=0;
L.listsize=LIST_INIT_SIZE;
return L;
}
sqlist interlist(Splist L, int i,int m)
{
int j,a;
if(i<1||i>L.length)
exit(printf("%s\n","ERROR:The delete position is illegal!"));
++L.length;
for(j=i-1;j<=L.length-1;j++)
L.elem[j]=L.elem[j-1];
return L;
}
Sqlist deletesqlist(Sqlist L,int i)
{
int j;
if(i<1||i>L.length)
exit(printf("%s\n","ERROR:The delete position is illegal!"));
for(j=i;j<=L.length-1;j++)
L.elem[j-1]=L.elem[j];
L.length--;
return L;
}
void main()
{
Sqlist L;
int i,k,e;
L=initlist(L);
for(i=1;i<=6;i++)
{
L.elem[i-1]=i;
L.length=L.length+1;
printf("%d\n",L.elem[i-1]);
}
printf("%s\n","below is the answer:");
prinf("\n s=");
if (s==0);
{
printf("\n k=");
scanf("%d",&k);
L=deletesqlist(L,k); }
else
printf("\n k= \n m=");
scanf("%d %d",&k &m);
L=interlist( L, k, m)
for(i=1;i<=L.length;i++)
printf("%d\n",L.elem[i-1]);
getch();
}