全部的代码
#include<stdio.h>
#include<malloc.h>
/**
*Linked list of integers. The key is data. The key is sorted in non-descending order.
*/
typedef struct LinkNode
{
int coefficient;
int exponent;
struct LinkNode *next;
}*LinkList, *NodePtr;
/**
*Initialize the list with a header.
*@return The pointer to the header.
*/
LinkList initLinkList()
{
LinkList tempHeader = (LinkList)malloc(sizeof(struct LinkNode));
tempHeader->coefficient = 0;
tempHeader->exponent = 0;
tempHeader->next = NULL;
return tempHeader;
}//of initLinkList
/**
*Print the list
*@param paraHeader The header of the list.
*/
void printList(LinkList paraHeader)
{
NodePtr p = paraHeader->next;
while (p != NULL)
{
printf("%d * 10^%d + ",p->coefficient, p->exponent);
p = p->next;
}//of while
printf("\r\n");
}//of printList
/**
*Print one node for testing.
*@param paraPtr The pointer to the node.
*@param paraChar The name of the node.
*/
void printNode(NodePtr paraPtr, char paraChar)
{
if(paraPtr == NULL)
{
printf("NULL\r\n");
}
else
{
printf("The element of %c is (%d * 10^%d)\r\n",paraChar,paraPtr->coefficient,paraPtr->exponent);
}//of while
}//of printNode
/**
*Add an element to the tail.
*@param paraCoefficient The coefficient of the new element.
*&#