cppstudio.com. Рассчет золотого сечения.


Решение

#include <iostream>
#include <iomanip>

using namespace std;

int main() {

    long double ans = 2.0;
    long long int num;


    cout << "How much?\n > ";
    cin >> num;
    for (int i = 1; i < num; i++) ans = 1+1/ans;
    cout << fixed << setprecision(1000) << "It is that much: " << ans << endl;
    return 0;
}

Видео выполнения:


Загрузки

Download files archive