Time for an 2014 update…
This commit is contained in:
parent
372c577f83
commit
09687c4926
2520 changed files with 34227 additions and 7318 deletions
|
|
@ -1,20 +1,21 @@
|
|||
import std.stdio, std.math, std.range, std.conv, std.algorithm;
|
||||
import std.stdio, std.math, std.conv, std.algorithm, std.array;
|
||||
|
||||
double f(in double x) pure nothrow {
|
||||
return x.abs().sqrt() + 5 * x ^^ 3;
|
||||
return x.abs.sqrt + 5 * x ^^ 3;
|
||||
}
|
||||
|
||||
void main() {
|
||||
double[] data;
|
||||
|
||||
while (true) {
|
||||
write("Please enter eleven numbers on a line: ");
|
||||
data = readln().split().map!(to!double)().array();
|
||||
"Please enter eleven numbers on a line: ".write;
|
||||
data = readln.split.map!(to!double).array;
|
||||
if (data.length == 11)
|
||||
break;
|
||||
writeln("Those aren't eleven numbers.");
|
||||
}
|
||||
foreach (x; data.retro()) {
|
||||
immutable y = f(x);
|
||||
writefln("f(%0.3f) = %s", x, y > 400 ? "Too large" : text(y));
|
||||
foreach_reverse (immutable x; data) {
|
||||
immutable y = x.f;
|
||||
writefln("f(%0.3f) = %s", x, y > 400 ? "Too large" : y.text);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue