Untitled

 avatar
unknown
plain_text
4 years ago
715 B
3
Indexable
#include"PListLib.c"
List readList(){
    List L ;
    makenullList(&L);
    int n;
    scanf("%d",&n);
    ElementType X ;
    for(int i = 0 ; i <= n ; i++){
        scanf("%d",&X);
        insertList(X,endList(L),&L);
    }
    return L;
}
void printList(List L){
    Position P = first(L) ;
    while(P!=endList(L)){
        printf("%d ",P->Element);
        P=P->Next;
    }
    printf("\n");
}
void removeAll(ElementType x, List *pL)
{
    while (locate(x, *pL)->Next != NULL)
        deleteList(locate(x, *pL), pL);
}
int main(){
    List L;
    L=readList();
    printList(L);
    ElementType x ;
    scanf("%d", &x);
    removeAll(x, &L);
    printList(L);
    return 0;
}
Editor is loading...