Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //Bc html interface. Just for fun, it's very ugly,rude and unefficient. But works.
- //Enrico Ronconi - 23 feb 2015
- $timeout = 5;
- $a = intval($_GET['a']);
- $b = intval($_GET['b']);
- $c = intval($_GET['c']);
- $cifre = intval($_GET['cifre']);
- if($cifre > 1000) die ("Non barare!");
- $start = microtime(true);
- $com = 'echo "scale = '.$cifre.'; a = '.$a.'*10^'.$_GET['ae'].'; b = '.$b.'*10^'.$_GET['be'].'; c = '.$c.'*10^'.$_GET['ce'].'; if ( (b^2-4*a*c) >= 0 ) {\"Radice 1: \"; (-b+sqrt(b^2-4*a*c))/(2*a); \"Radice 2: \"; (-b-sqrt(b^2-4*a*c))/(2*a); } else { \"Nessuna soluzione reale\" }" | timeout -s9 '.$timeout.' bc';
- exec($com,$out);
- $tempo = round(microtime(true)-$start,4);
- echo('
- <html>
- <body>
- Il calcolo ha richiesto circa '.$tempo.' secondi. (Timeout impostato a '.$timeout.' secondi)<p> Risultato: <p>
- <hline>
- <tt> '.str_replace("Radice 2:","</br></br>Radice 2:",str_replace("\\</br>","",implode("</br>",$out))).' </tt>
- </body>
- </html>');
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement