Home > Back-end >  2. Write the algorithm to calculate in A given each coefficient polynomials and the value of the var
2. Write the algorithm to calculate in A given each coefficient polynomials and the value of the var

Time:10-07

This problem have who can teach me?   is really can't do it

CodePudding user response:

A0 + a1 * x ^ 1. + a2 * x ^ 2 +... + an * x ^ n
The fastest algorithm is:
A0 (a1 + x + x * * * (a2 + x (... + x * (an)))))))

Write function is:
Float poly real (float a [], int n, float x) {
Float result=0;
For (int v=n; V>=0; V -)
Result=a [v] + x * result;
return result;
}

Int main () {
Float a [100]={1, 2, 3};//for coefficient of ai, said 1 + 2 + 3 * * x x x x
Int n=2;//polynomial highest item is square project
Float x=3;
Float ans=poly real (a, n, x);
Printf (" % f ", ans);
return 0;
};

CodePudding user response:

If x ^ 3 + 1;
Float a [100]={1, 0, 0, 1};//+ 0/+ 0 * x * x * x + 1 the meaning of * * * x x x
Int n=3;

Specific how to input the polynomial and the value of x, can write their own code
Key fn (x) is the poly real function

CodePudding user response:

Fun
reference 1 floor response:
a0 + a1 * x ^ 1. + a2 * x ^ 2 +... + an * x ^ n
The fastest algorithm is:
A0 (a1 + x + x * * * (a2 + x (... + x * (an)))))))

Write function is:
Float poly real (float a [], int n, float x) {
Float result=0;
For (int v=n; V>=0; V -)
Result=a [v] + x * result;
return result;
}

Int main () {
Float a [100]={1, 2, 3};//for coefficient of ai, said 1 + 2 + 3 * * x x x x
Int n=2;//polynomial highest item is square project
Float x=3;
Float ans=poly real (a, n, x);
Printf (" % f ", ans);
return 0;
};

Is to write directly?

CodePudding user response:

Whatever you say
See the topic full requirements of the
Are basic assignment operations, to go write himself

CodePudding user response:

Fun
reference 4 floor response:
with you
See the topic full requirements of the
Are basic assignment operations, write their own go

Who can help me to write???????????

CodePudding user response:

Can't

Must write their own
Learn to write their own; Up the wrong post code can help to change
Want to want to code, baidu to himself
  • Related