Files
algorithms/list.cpp
Aryadev Chavali fccfcd4a9f (list)~struct List is not necessary
Slight whiplash from change to C++, can just use typename now.
2021-11-20 22:40:56 +00:00

41 lines
595 B
C++

/* 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>
List<T> *append(List<T> *lst, T value)
{
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;
}