From 9b48d05c446997a3e953107898f7f0336be470d5 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Wed, 19 Aug 2020 21:42:40 +0200 Subject: Update cbrt.cc alternative way, more easy --- I_anno/Programmazione_2/algorithms/cbrt.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'I_anno/Programmazione_2/algorithms') diff --git a/I_anno/Programmazione_2/algorithms/cbrt.cc b/I_anno/Programmazione_2/algorithms/cbrt.cc index bbd1ee1..30c7792 100644 --- a/I_anno/Programmazione_2/algorithms/cbrt.cc +++ b/I_anno/Programmazione_2/algorithms/cbrt.cc @@ -16,6 +16,19 @@ int cbrt(int n) { return q; } +double cbrt2(int n) { + int i = 1; + while(i*i*i <= n) + ++i; + // precision + + --i; + while(i*i*i < n) + i+=0.000001; + + return i; +} + int main() { int i; cin >> i; -- cgit v1.2.3-18-g5258