blob: 8c671a151292c4bcc492c4d967ca22617e815132 (
plain)
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
|
/* list.cpp
* Date: 2021-11-20
* Author: Aryadev Chavali
*/
#include <cstdio>
#include <cstdlib>
template <typename T>
struct List
{
T value;
struct List<T> *next;
};
template <typename T>
struct List<T> *append(struct List<T> *lst, T value)
{
struct List<T> *node;
if (lst == NULL)
{
node = new List<T>;
node->value = value;
node->next = NULL;
return node;
}
for (node = lst; node->next != NULL; node = node->next)
continue;
node->next = new List<T>;
node->next->value = value;
node->next->next = NULL;
return lst;
}
int main(void)
{
return 0;
}
|