Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main(){
  4.  
  5.  
  6. double x[5]= {20,23,26,29,32};
  7.  
  8. double y[5][5]= {0.00};
  9. y[0][0]=0.3420;
  10. y[1][0]=0.3907;
  11. y[2][0]=0.4384;
  12. y[3][0]=0.4848;
  13. y[4][0]=0.5295;
  14.  
  15. int i,j,row,col,n=5;
  16. for(i=1; i<n; i++)
  17. {
  18.  
  19. for(j=0; j<n-i; j++)
  20. y[j][i]=y[j+1][i-1]-y[j][i-1];
  21. }
  22. for( row=0; row<n; row++)
  23. {
  24.  
  25. cout<<x[row];
  26. for( col=0; col<n-row; col++)
  27. printf("%f ",y[row][col]);
  28. cout<<endl;
  29.  
  30.  
  31.  
  32. }
  33. double p=(double)(21-20)/3;
  34. cout<<"P= "<<p<<endl;
  35. double fx=y[0][0]+p*y[0][1]+((p*(p-1))/2*1)*y[0][2]+((p*(p-1)*(p-2))/3*2*1)*y[0][3]+((p*(p-1)*(p-1)*(p-3)/4*3*2*1)*y[0][4]);
  36. cout<<"Fx= "<<fx;
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement