Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- const int TAMANHO = 5;
- using namespace std;
- int main( void)
- {
- int l, j;
- double x[ TAMANHO] = { -1, 0, 1, 2, 3 } ;
- double y[ TAMANHO] = { 1, 1, 0, -1, -2 } ;
- double p, acum_1, acum_2;
- p = 3.2;
- acum_1 = 0;
- for( l = 0; l < TAMANHO; l++)
- {
- acum_2 = 1;
- for( j = 0; j < TAMANHO; j++)
- {
- if( j != l)
- {
- acum_2 *= ( p - x[ j]);
- acum_2 /= ( x[ l] - x[ j]);
- }
- }
- cout << "y" << l << "L" << l << ": " << y[ l] << ", " << acum_2 << endl ;
- acum_2 *= y[ l];
- acum_1 += acum_2;
- }
- cout << "Valor de p: " << acum_1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement