#include "library.h" #include double squares(double x) { return x * x; } int find(double minpos, double maxpos, int s) { double half = (minpos + maxpos) / 2; cout << minpos << " - " << setprecision(10) << half << " - " << maxpos << "\n"; if (maxpos - minpos < 0.00001) return half; if (s < squares(half)) return find(minpos, half, s); if (s > squares(half)) return find(half, maxpos, s); return half; } void main() { cout << "square to search "; const int s = read_int(); const int pos = find(0, 32768, s); if (pos == -1) cout << "not found\n"; else cout << "result: " << pos << ": " << squares(pos) << "\n"; }