Home > Back-end >  One yuan polynomial great god will look at this is what warning evaluation, thank you
One yuan polynomial great god will look at this is what warning evaluation, thank you

Time:10-24

# include & lt; stdio.h>
# include & lt; Stdlib. H>
# include & lt; Math. H>

Typedef struct
{
int coef;/* coef of pn */
Int exp./* exp of pn */
} PolyTerm;
Typedef struct
{
Int length;
PolyTerm * data;
} SqPoly;

Float the Evaluate (SqPoly pn, float x)
{
Float sum=0;
int i;
for (i=0; iSum +=pn. Data [I] coef * pow (x, pn. Data [I]. Exp);
Printf (" The result is: % f ", sum);
return 0;
}

Int main (void)
{
Float the Evaluate (SqPoly pn, float x);
Int I, n;
SqPoly pn;
PolyTerm data;
Float x, f1;
CLRSCR ();
Printf (" do input the terms of the number of the pn: \ n ");
The scanf (" % d ", & amp; N);
data. Coef=(int *) malloc (sizeof (int) * n);
Data. J exp=(int *) malloc (sizeof (int) * n);
here the compiler will be prompted to two Non - portable pointer the assignment function in the main solving
Pn. Length=n;
Printf (" do input the coef of the pn: \ n ");
for (i=0; iThe scanf (" % d ", & amp; Pn. Data [I] coef);
Printf (" do input the exp of the pn: \ n ");
for (i=0; iThe scanf (" % d ", & amp; Pn. Data [I]. J exp);
Printf (" do input the x to solve: ");
The scanf (" % f ", & amp; X);
Evaluate (pn, x);
return 0;
}
Finally, there is a warning data is assigned as a value whichi is never informs the
This is under the environment of TC2.0, a preliminary study

CodePudding user response:

Pn. Data=https://bbs.csdn.net/topics/(PolyTerm *) malloc (sizeof (PolyTerm) * n);

CodePudding user response:

Float the Evaluate (SqPoly pn, float x);

Int main (void)
{
Int I, n;
SqPoly pn;
PolyTerm data;
Float x, f1;
CLRSCR ();
Printf (" do input the terms of the number of the pn: \ n ");
The scanf (" % d ", & amp; N);
pn. Data=https://bbs.csdn.net/topics/(PolyTerm *) malloc (sizeof (PolyTerm) * n);
Pn. Length=n;
Printf (" do input the coef of the pn: \ n ");
for (i=0; iThe scanf (" % d ", & amp; Pn. Data [I] coef);
Printf (" do input the exp of the pn: \ n ");
for (i=0; iThe scanf (" % d ", & amp; Pn. Data [I]. J exp);
Printf (" do input the x to solve: ");
The scanf (" % f ", & amp; X);
Evaluate (pn, x);
return 0;
}
  • Related