Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 81 Solved: 66
[Submit] [Status] [Web Board] Linear Table A with A known length of n in Description adopts A sequential storage structure. Write an algorithm with A time complexity of 0 (n) and A space complexity of 0 (1, this algorithm deletes all data elements whose values are item in a linear table. (O (1) indicates that the auxiliary space of the algorithm is constant ). Input
Input n: 6
Input data: 1 2 3 4 5 6
Input item: 5
Output
Output: 1 2 3 4 6
Sample Input101 2 3 4 5 6 7 8 9 108 Sample Output1 2 3 4 5 6 7 9 10
# Include
Using namespace std; struct mm {int a; mm * p ;}; int main () {int n, m; mm * head, * k, * h; cin> n; head = new mm; k = head; while (n --) {cin> k-> a; k-> p = new mm; h = k; k = k-> p; k-> p = NULL;} cin> m; delete k; h-> p = NULL; h = k = head; while (head-> a = m) {head = head-> p;} h = k = head; while (k! = NULL) {if (k-> a = m) {h-> p = k-> p; k = h;} h = k; k = k-> p;} k = head; while (k! = NULL) {cout <
A <''; k = k-> p;} return 0 ;}