This repository has been archived on 2021-11-27. You can view files and clone it, but cannot push or open issues or pull requests.
5 changed files with
81 additions and
0 deletions
|
|
|
@ -0,0 +1,15 @@
|
|
|
|
|
.dub
|
|
|
|
|
docs.json
|
|
|
|
|
__dummy.html
|
|
|
|
|
docs/
|
|
|
|
|
/example_8
|
|
|
|
|
example_8.so
|
|
|
|
|
example_8.dylib
|
|
|
|
|
example_8.dll
|
|
|
|
|
example_8.a
|
|
|
|
|
example_8.lib
|
|
|
|
|
example_8-test-*
|
|
|
|
|
*.exe
|
|
|
|
|
*.o
|
|
|
|
|
*.obj
|
|
|
|
|
*.lst
|
|
|
|
@ -0,0 +1,9 @@
|
|
|
|
|
{
|
|
|
|
|
"authors": [
|
|
|
|
|
"Alexander"
|
|
|
|
|
],
|
|
|
|
|
"description": "Интерфейсы и классы",
|
|
|
|
|
"license": "proprietary",
|
|
|
|
|
"name": "example_8",
|
|
|
|
|
"targetPath": "bin"
|
|
|
|
|
}
|
|
|
|
@ -0,0 +1,26 @@
|
|
|
|
|
import std.stdio : writeln, stdin;
|
|
|
|
|
import std.exception : enforce;
|
|
|
|
|
import min_, stat_;
|
|
|
|
|
|
|
|
|
|
void main(string[] args)
|
|
|
|
|
{
|
|
|
|
|
Stat[] stats;
|
|
|
|
|
foreach (arg; args[1 .. $])
|
|
|
|
|
{
|
|
|
|
|
auto newStat = cast(Stat) Object.factory("min_." ~ arg);
|
|
|
|
|
enforce(newStat, "Invalid statistics function: " ~ arg);
|
|
|
|
|
stats ~= newStat;
|
|
|
|
|
}
|
|
|
|
|
for (double x; stdin.readf(" %s ", &x) == 1;)
|
|
|
|
|
{
|
|
|
|
|
foreach (s; stats)
|
|
|
|
|
{
|
|
|
|
|
s.accumulate(x);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
foreach (s; stats)
|
|
|
|
|
{
|
|
|
|
|
s.postprocess();
|
|
|
|
|
writeln(s.result());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -0,0 +1,23 @@
|
|
|
|
|
module min_;
|
|
|
|
|
|
|
|
|
|
import stat_;
|
|
|
|
|
|
|
|
|
|
class Min : Stat
|
|
|
|
|
{
|
|
|
|
|
private double min = double.max;
|
|
|
|
|
|
|
|
|
|
void accumulate(double x)
|
|
|
|
|
{
|
|
|
|
|
if (x < min)
|
|
|
|
|
{
|
|
|
|
|
min = x;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void postprocess() {}
|
|
|
|
|
|
|
|
|
|
double result()
|
|
|
|
|
{
|
|
|
|
|
return min;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -0,0 +1,8 @@
|
|
|
|
|
module stat_;
|
|
|
|
|
|
|
|
|
|
interface Stat
|
|
|
|
|
{
|
|
|
|
|
void accumulate(double x);
|
|
|
|
|
void postprocess();
|
|
|
|
|
double result();
|
|
|
|
|
}
|