#include#include #define OK 1; typedef int status; typedef int ElemType; typedef struct { ElemType *elem; int length; int listlize; }SqList; status InitList(SqList *L,int len) { L->elem = (int*)malloc(sizeof(int)*len); L->length = len ; return OK; } void DeleteList(SqList *L,int i) { int *p; int *q; p = &(L->elem[i]); q = L->elem + L->length - 1; for (*p; p < q; p++) { *p = *(p + 1); } --L->length; } int main(void) { SqList L; int len,i; int *p, *q; printf("请输入你将要输入数字的个数:"); scanf("%d", &len); InitList(&L, len); printf("输入您想输入的数值:"); for (i = 0; i < len; i++) { scanf("%d", &L.elem[i]); printf(" "); } printf("n"); p = L.elem; q = L.elem + 1; i = 1; while (L.length>i) { if (*p == *q) { DeleteList(&L, i); } else { p++; q++; i++; } } printf("删改后的数据为:n"); for (i = 0; i < L.length; i++) { printf("%dt", L.elem[i]); } return 0; }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)