List MakeEmpty(); Position Find( List L, ElementType X ); boolInsert( List L, ElementType X, Position P ); boolDelete( List L, Position P );
intmain() { List L; ElementType X; Position P; int N;
L = MakeEmpty(); scanf("%d", &N); while ( N-- ) { scanf("%d", &X); if ( Insert(L, X, 0)==false ) printf(" Insertion Error: %d is not in.\n", X); } scanf("%d", &N); while ( N-- ) { scanf("%d", &X); P = Find(L, X); if ( P == ERROR ) printf("Finding Error: %d is not in.\n", X); else printf("%d is at position %d.\n", X, P); } scanf("%d", &N); while ( N-- ) { scanf("%d", &P); if ( Delete(L, P)==false ) printf(" Deletion Error.\n"); if ( Insert(L, 0, P)==false ) printf(" Insertion Error: 0 is not in.\n"); } return0; }
/* 你的代码将被嵌在这里 */
输入样例:
1 2 3 4 5 6
6 1 2 3 4 5 6 3 6 5 1 2 -1 6
输出样例:
1 2 3 4 5 6 7 8
FULL Insertion Error: 6 is not in. Finding Error: 6 is not in. 5 is at position 0. 1 is at position 4. POSITION -1 EMPTY Deletion Error. FULL Insertion Error: 0 is not in. POSITION 6 EMPTY Deletion Error. FULL Insertion Error: 0 is not in.