Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- double x;
- cin >> x;
- double mid, temp, check = 0;
- double low = 0, high = x;
- mid = (low + high) / 2;
- while((mid * mid) != x){
- if(check != 0) mid = (low + high) / 2;
- check = 1;
- temp = mid * mid;
- if(temp > x){
- high = mid;
- }
- else if(temp < x){
- low = mid;
- }
- }
- cout << mid << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement