Exemplo n.º 1
0
// make a physical copy of a list
// new list looks identical to original list
IntList IntListCopy(IntList L)
{
	struct IntListRep *Lnew;
	struct IntListNode *curr;

	Lnew = newIntList();
	for (curr = L->first; curr != NULL; curr = curr->next)
		IntListInsert(Lnew, curr->data);
	return Lnew;
}
Exemplo n.º 2
0
// create an IntList by reading values from a file
// assume that the file is open for reading
IntList getIntList(FILE *inf)
{
	IntList L;
	int v;

	L = newIntList();
	while (fscanf(inf,"%d",&v) != EOF)
		IntListInsert(L,v);
	return L;
}
Exemplo n.º 3
0
// insert an integer into correct place in a sorted list
void IntListInsertInOrder(IntList L, int v)
{
    // This is INCORRECT
    IntListInsert(L, v);
}