~cpp #include <iostream.h> struct node{ int data; node * node_pointer; }; node * INSERT(node * head_pointer, int num); node * DELETE(node * head_pointer); int main() { // node * head_pointer = new node; // 기 head_pointer = NULL; int num, choice; // cout << " !!\n"; cout << "1.push 2.pop 3.exit\nchoice : "; cin >> choice; while(choice != 3) { switch(choice) { case 1://push cout << "push num : "; cin >> num; head_pointer = INSERT(head_pointer, num); break; case 2://pop head_pointer = DELETE(head_pointer); break; } cout << "\n !!\n"; cout << "1.push 2.pop 3.exit\nchoice : "; cin >> choice; } return 0; } // node * INSERT(node * head_pointer, int num) { node * temp = new node; // if(head_pointer == NULL) { head_pointer = temp; head_pointer->data = num; head_pointer->node_pointer = NULL; } else { temp->node_pointer = head_pointer; head_pointer = temp; head_pointer->data = num; } return head_pointer; } // node * DELETE(node * head_pointer) { node * temp = new node; // if(head_pointer == NULL) cout << "no data in stack" << "\n"; else { cout << "delete num : " << head_pointer->data << "\n"; temp = head_pointer; head_pointer = head_pointer->node_pointer; delete temp; } return head_pointer; }