Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <cmath>
- #include <iomanip>
- using namespace std;
- int main()
- {
- int n;
- double a = 1.0, precision = 0.000001, b;
- ifstream fr ("U1.txt");
- ofstream fw ("U1rez.txt");
- fr >> n;
- while (a * a != n)
- {
- b = n / a;
- a =(a + b) / 2;
- if (a < precision)
- {
- break;
- }
- }
- fw << fixed << setprecision(6) << a;
- fr.close();
- fw.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment