Notes![what is notes.io? What is notes.io?](/theme/images/whatisnotesio.png)
![]() ![]() Notes - notes.io |
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
struct node
{
int no;
struct node *next;
};
int main()
{
int choice;
struct node *head, *temp, *p;
do
{
cout << "n1 to make listn";
cout << "2 to insert at begeningn";
cout << "3 to insert at end n";
cout << "4 to insert at desiren";
cout << "5 to delete begeningn";
cout << "6 to delete at endn";
cout << "7 to delete at desiren";
cout << "8 to displayn";
cout << "9 to quitn";
cout << "enter your choice";
cin >> choice;
if (choice == 1)
{
int a;
cout << "enter head node value";
cin >> a;
head = (struct node *)malloc(sizeof(struct node));
head->no = a;
head->next = 0;
p = head;
for (int i = 0; i < 3; i++)
{
int b;
cout << "enter no for parent node";
cin >> b;
temp = (struct node *)malloc(sizeof(struct node));
temp->no = b;
temp->next = 0;
p->next = temp;
p = p->next;
}
}
else if (choice == 2)
{
int c;
cout << "enter to insert at begening";
cin >> c;
temp = (struct node *)malloc(sizeof(struct node));
temp->no = c;
temp->next = head;
head = temp;
}
else if (choice == 3)
{
int d;
cout << "enter no to insert at end";
cin >> d;
temp = (struct node *)malloc(sizeof(struct node *));
temp->no = d;
temp->next = 0;
p = head;
while (p->next != NULL)
{
p = p->next;
}
p->next = temp;
}
else if (choice == 4)
{
int flag = false, e;
cout << "enter no to insert after";
cin >> e;
p = head;
while (p != NULL)
{
if (p->no == e)
{
flag = true;
break;
}
p = p->next;
}
if (flag == true)
{
int f;
cout << "no to replace before";
cin >> f;
temp = (struct node *)malloc(sizeof(struct node *));
temp->no = f;
temp->next = p->next;
p->next = temp;
}
else
{
cout << "not found";
}
}
else if (choice == 5)
{
p = head;
head = head->next;
free(p);
}
else if (choice == 6)
{
p = head;
while (p->next != NULL)
{
temp = p;
p = p->next;
}
temp->next = NULL;
}
else if (choice == 7)
{
int x, flag1 = false;
cout << "enter no to delete desire";
cin >> x;
p = head;
while (p != NULL)
{
if (p->no == x)
{
flag1 = true;
break;
}
temp = p;
p = p->next;
}
temp->next = p->next;
free(p);
}
else if (choice == 8)
{
p = head;
cout << "link list=";
while (p != NULL)
{
cout << p->no << " ";
p = p->next;
}
}
} while (choice != 9);
}
![]() |
Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 12 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team