-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1test.c
More file actions
64 lines (48 loc) · 796 Bytes
/
1test.c
File metadata and controls
64 lines (48 loc) · 796 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <stdio.h>
#include <stdlib.h>
#define listsize 100
int length1=10;
int Add(int *p,int e,int number)
{
int *q=p+length1-e;
int *m;
if(length1>=listsize)
{
int *newbase=(int *)realloc(p,(listsize)*sizeof(int));
m=newbase;
}
for(p=p+length1-1;p>=q;--p)
{
*(p+1)=*p;
*q=e;
++length1;
return 1;
}
}
int *q;
int Delte(int *p,int e)
{
if((e<1)||(e>length1))
{
printf("Error ,please try again");
return 0;
}
q=p+length1-1; //表尾元素的位置
p=p+length1-e;//被删除元素的位置;
for(++p;p<=q;++p)
{
*(p-1)=*p;
}
--length1;
return 1;
}
void main()
{
int array[10]={1,5,4,3,2,1,2,2};
if(Add(array,2,5))
{
int i;
for(i=0;i<=length1;i++)
printf("array[%d]=%d\n",i,array[i]);
}
}