Page 170, Exercise 4
Call: a = ReadPoly();
|
PolyPointer ReadPoly()
{/*read in the polynomial */
PolyPointer node,c;
float coefficient;
int exponent;
node = GetNode();
node->coef = -1.0;
node->expon = -1;
node->link = node;
printf("Enter an exponent < 0 to quit: ");
printf("\nCoefficient, Exponent: ");
scanf("%f,%d",&coefficient,&exponent);
while (exponent >= 0) {
c = GetNode();
c->coef = coefficient;
c->expon = exponent;
c->link = node->link;
node->link = c;
printf("Coefficient, Exponent: ");
scanf("%f,%d",&coefficient,&exponent);
}
return node;
} |