-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path15.cpp
More file actions
48 lines (41 loc) · 737 Bytes
/
15.cpp
File metadata and controls
48 lines (41 loc) · 737 Bytes
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
#include <iostream>
using namespace std;
struct List
{
int x;
List *Next,*Head;
};
void Add(int x, List *&MyList)
{
List *temp=new List;
temp->x=x;
temp->Next=MyList->Head;
MyList->Head=temp;
}
void Show(List *MyList)
{
List *temp=MyList->Head;
while (temp!=NULL)
{
cout<<temp->x<<" ";
temp=temp->Next;
}
}
void Destr(List *MyList)
{
while (MyList->Head!=NULL)
{
List *temp=MyList->Head->Next;
delete MyList->Head;
MyList->Head=temp;
}
}
int main()
{
List *MyList=new List;
MyList->Head=NULL;
for (int i=0;i<10;i++)
Add(i,MyList);
Show(MyList);
Destr(MyList);
}