-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStudent information.cpp
218 lines (198 loc) · 6.26 KB
/
Student information.cpp
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
#include<iostream>
#include<string.h>
using namespace std;
struct node
{ int prn,rollno;
char name[50];
struct node *next;
};
class info
{ node *s=NULL,*head1=NULL,*temp1=NULL,*head2=NULL,*temp2=NULL,*head=NULL,*temp=NULL;
int b,c,i,j,ct;
char a[20];
public:
node *create();
void insertp();
void insertm();
void delm();
void delp();
void dels();
void display();
void count();
void reverse();
void rev(node *p);
void concat();
} ;
node *info::create()
{ node *p=new(struct node);
cout<<"Enter name of student :";
cin>>a;
strcpy(p->name,a);
cout<<"\nEnter PRN No. of student :";
cin>>b;
p->prn=b;
cout<<"Enter student Roll No :";
cin>>c;
p->rollno=c;
p->next=NULL;
return p;
}
void info::insertm()
{
node *p=create();
if(head==NULL)
{ head=p;
}
else
{ temp=head;
while(temp->next!=NULL)
{ temp=temp->next; }
temp->next=p;
}
}
void info::insertp()
{
node *p=create();
if(head==NULL)
{ head=p;
}
else
{ temp=head;
head=p;
head->next=temp->next;
}
}
void info::display()
{ if(head==NULL)
{ cout<<"linklist is empty";
}
else
{
temp=head;
cout<<" PRN Rollno NAME \n";
while(temp->next!=NULL)
{ cout<<" \n"<<temp->prn<<" "<<temp->rollno<<" "<<temp->name;
temp=temp->next;
}
cout<<" "<<temp->prn<<" "<<temp->rollno<<" "<<temp->name;
}
}
void info::delm()
{ int m,f=0;
cout<<"\n enter the prn no. of student whose data you want to delete";
cin>>m;
temp=head;
while(temp->next!=NULL)
{
if(temp->prn==m)
{ s->next=temp->next;
delete(temp); f=1;
}
s=temp;
temp=temp->next;
} if(f==0)
{ cout<<"\n sorry memeber not deleted "; }
}
void info::delp()
{ temp=head;
head=head->next;
delete(temp);
}
void info::dels()
{
temp=head;
while(temp->next!=NULL)
{ s=temp;
temp=temp->next;
} s->next=NULL;
delete(temp);
}
void info::count()
{ temp=head; ct=0;
while(temp->next!=NULL)
{ temp=temp->next; ct++; }
ct++;
cout<<" Count of members is:"<<ct;
}
void info::reverse()
{ rev(head); }
void info::rev(node *temp)
{ if(temp==NULL)
{ return; }
else
{ rev(temp->next); }
cout<<" "<<temp->prn<<" "<<temp->rollno<<" "<<temp->name;
}
void info::concat()
{ int k,j;
cout<<"enter no. of members in list1";
cin>>k;
head=NULL;
for(i=0;i<k;i++)
{ insertm();
head1=head;
} head=NULL;
cout<<"enter no. of members in list2";
cin>>j;
for(i=0;i<j;i++)
{ insertm();
head2=head;
} head=NULL;
temp1=head1;
while(temp1->next!=NULL)
{ temp1=temp1->next; }
temp1->next=head2;
temp2=head1;
cout<<" prn rolln0 NAME \n";
while(temp2->next!=NULL)
{
cout<<"\n "<<temp2->prn<<" "<<temp2->rollno<<" "<<temp2->name<<"\n";;
temp2=temp2->next;
}
cout<<"\n "<<temp2->prn<<" "<<temp2->rollno<<" "<<temp2->name<<"\n";
}
int main()
{ info s;
int i;
char ch;
do{
cout<<"\n choice the options";
cout<<"\n 1. To insert president ";
cout<<"\n 2. To insert member ";
cout<<"\n 3. To insert secretary ";
cout<<"\n 4. To delete president ";
cout<<"\n 5. To delete member ";
cout<<"\n 6. To delete secretary ";
cout<<"\n 7. To display data ";
cout<<"\n 8. Count of members";
cout<<"\n 9. To display reverse of string ";
cout<<"\n 10.To concatenate two strings ";
cin>>i;
switch(i)
{ case 1: s.insertp();
break;
case 2: s.insertm();
break;
case 3: s.insertm();
break;
case 4: s.delp();
break;
case 5: s.delm();
break;
case 6: s.dels();
break;
case 7: s.display();
break;
case 8: s.count();
break;
case 9: s.reverse();
break;
case 10: s.concat();
break;
default: cout<<"\n unknown choice";
}
cout<<"\n Do you want to continue enter y/n \n";
cin>>ch;
}while(ch=='y'||ch=='Y');
return 0;
}