예제 #1
0
int main()
{
  
    struct node *head;
    head=(struct node *)malloc(sizeof(struct node));
    create(head,5);
    head=insert_middle(head,45);
    display(head);

    return 0;
}
int main()
{
    int ch ;
    char choice;
    do
    {
        printf("Main menu:\n");
        printf("1 Create a list\n");
        printf("2 Insert in the beginning\n");
        printf("3 Insert in the middle\n");
        printf("4 Insert at the end\n");
        printf("Enter your choice\n");
        scanf("%d" , &ch);
        switch(ch)
        {
            case 1 : create();
                     break;
            case 2 : printf("Enter the value you want to insert : ");
                     scanf("%d" , &a);
                     insert_beg();
                     break;
            case 3 : printf("Enter the value you want to insert : ");
                     scanf("%d" , &a);
                     printf("Eter the value after which you want to insert : ");
                     scanf("%d" , &X);
                     insert_middle();
                     break;
            case 4 : printf("Enter the value you want to insert : ");
                     scanf("%d" , &a);
                     insert_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;
}