Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. double height(double mass[], int n){
  2. double l=0;
  3. double r;
  4. r = mass[0];
  5. while (r-l>0.0000001){
  6. mass[1]=(l+r)/2;
  7. bool Up = true;
  8. for (int i=2; i<n; i++){
  9. mass[i]=2*mass[i-1]-mass[i-2]+2;
  10. if (mass[i]<0){
  11. Up= false;
  12. break;
  13. }
  14. }
  15. if (Up==true) {
  16. r = mass[1];
  17. }
  18. else {
  19. l = mass[1];
  20. }
  21. }
  22. return mass[n-1];
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement