Write a PHP program which solve the equation:ax+by=cdx+ey=fPrint the values of x, y where a, b, c, d, e and f are given.
Input:a,b,c,d,e,f separated by a single space.(-1,000 ≤ a,b,c,d,e,f ≤ 1,000)
<?php function to_f($e) { return (float)$e; } while($line = fgets(STDIN)) { $a = explode(" ", $line); $a = array_map("to_f", $a); $x = ($a[2]*$a[4]-$a[1]*$a[5])/($a[0]*$a[4]-$a[3]*$a[1]); $y = ($a[2]*$a[3]-$a[0]*$a[5])/($a[1]*$a[3]-$a[0]*$a[4]); print("Values of x and y:\n"); printf("%.3f %.3f\n", $x, $y); } ?>
Sample Output:
Values of x and y: -1.684 2.737
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer