void print(LinkQueue Q) { QueuePtr p = Q.front ->next; while (p) { cout << p->data <<" "; p = p->next; } } int main() { LinkQueue q; InitQueue(q); printf("请输入度列的长度: "); int n; cin >> n; for (int i = 0; i < n; i++) { int temp; cin >> temp; EnQueue(q, temp); } print(q); cout << endl; LinkQueue t = q; cout << t.front<<endl; cout << t.rear << endl; cout << t.front->next->data << t.rear->data <<endl; DeQueue(q); print(q); cout << endl; EnQueue(q,5); print(q); cout << endl; if(DestroyQueue(q)) cout << "Destroy Queue completely"; return 0; }
|