int main() { node* head = new node(0); node* app = head; for(int i = 0; i < 10; ++i) { append(app, i); app = app->next; } delete_middle(head); node* curr = head; while(curr) { std::cout << curr->data << " "; curr = curr->next; } std::cout << std::endl; delete_list(head); }
int main() { struct stack *ms=NULL; ms=push(ms, 11); ms=push(ms, 22); ms=push(ms, 33); ms=push(ms, 44); ms=push(ms, 55); ms=push(ms, 66); ms=push(ms, 77); delete_middle(); printf("Middle Element is %d\n", find_middle()); printf("Item popped is %d\n", pop(&ms)); printf("Middle Element is %d\n", find_middle()); printf("Item popped is %d\n", pop(&ms)); printf("Middle Element is %d\n", find_middle()); }
int main() { int ch ; char choice; do { printf("Main menu:\n"); printf("1 Create a list\n"); printf("2 Delete the first node\n"); printf("3 Delete an intermediate node\n"); printf("4 Delete the last node\n"); printf("Enter your choice\n"); scanf("%d" , &ch); switch(ch) { case 1 : create(); break; case 2 : delete_beg(); break; case 3 : printf("Enter the value you want to delete : "); scanf("%d" , &X); delete_middle(); break; case 4 : delete_end(); break; default : printf("Wrong choice\n"); break; } printf("\nDo u want to continue..??\n"); fflush(stdin); scanf("%c" , &choice); printf("\n"); }while((choice=='y')||(choice=='Y')); display(); return 0; }