-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsll_student.cpp
More file actions
66 lines (65 loc) · 2.25 KB
/
Copy pathsll_student.cpp
File metadata and controls
66 lines (65 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <iostream>
#include "student.h"
#include "single_linked_list_node.h"
#include "single_linked_list_list.h"
using namespace std;
int main()
{
int i, n;
int choice;
single_linked_list_list *single_linked_list_list_l = new single_linked_list_list;
single_linked_list_node *single_linked_list_node_n;
printf("\nINFORMATION\n");
do
{
printf(" \n 1. Create a linked Student single linked list \n 2. Display linked Student single linked list \n 3. Insert a Student single linked list node at last \n 4. Insert a Student single_linked_list_node at front \n 5. Delete a Student single linked list node at last\n 6. Delete a Student single linked list node at first \n 7.Exit \n");
printf("\nEnter your choice \n");
scanf("%d", &choice);
switch (choice)
{
case 1:
printf("\nHow many students information has to be entered\n");
scanf("%d", &n);
for (i = 0; i < n; i++)
{
student *s = new student();
s->initialize();
single_linked_list_node_n = new single_linked_list_node(s);
single_linked_list_list_l->insert_at_end(single_linked_list_node_n);
}
break;
case 2:
single_linked_list_list_l->display();
break;
case 3:
{
student *s1 = new student();
s1->initialize();
single_linked_list_node_n = new single_linked_list_node(s1);
single_linked_list_list_l->insert_at_end(single_linked_list_node_n);
}
break;
case 4:
{
student *s2 = new student();
s2->initialize();
single_linked_list_node_n = new single_linked_list_node(s2);
single_linked_list_list_l->insert_at_first(single_linked_list_node_n);
}
break;
case 5:
single_linked_list_list_l->delete_at_last();
break;
case 6:
single_linked_list_list_l->delete_at_first();
break;
case 7:
exit(0);
break;
default:
printf("\nEnter correct choice\n");
break;
}
} while (choice != 6);
free(single_linked_list_list_l);
}