home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_09_03
/
9n03120a
< prev
next >
Wrap
Text File
|
1991-01-16
|
758b
|
44 lines
/*
* ln_seq.cpp - line number sequence implementation
*/
#include <stdio.h>
#include "ln_seq.h"
ln_seq::ln_seq()
{
first = 0;
}
void ln_seq::add(unsigned n)
{
listnode *p = first;
if (first == 0)
{
first = new listnode;
first->number = n;
first->next = NULL;
}
else
{
while (p->next != 0 && p->number != n)
p = p->next;
if (p->number != n)
{
p = p->next = new listnode;
p->number = n;
p->next = 0;
}
}
}
void ln_seq::print()
{
listnode *p;
for (p = first; p != 0; p = p->next)
printf("%4d ", p->number);
}