fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. double l=0, r=2;
  6. for (int i=0; i<100; i++) {
  7. double m=(l+r)/2;
  8. (m*m<2?l:r)=m;
  9. }
  10. cout<<l<<endl;
  11. return 0;
  12. }
  13.  
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
1.41421