Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
28
Task/Price-fraction/Seed7/price-fraction-1.seed7
Normal file
28
Task/Price-fraction/Seed7/price-fraction-1.seed7
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
$ include "seed7_05.s7i";
|
||||
include "float.s7i";
|
||||
|
||||
const func float: computePrice (in float: x) is func
|
||||
result
|
||||
var float: price is 0.0;
|
||||
begin
|
||||
if x >= 0.0 and x < 0.06 then
|
||||
price := 0.10;
|
||||
elsif x < 0.11 then
|
||||
price := 0.18;
|
||||
elsif x < 0.36 then
|
||||
price := flt(((trunc(x * 100.0) - 11) div 5) * 6 + 26) / 100.0;
|
||||
elsif x < 0.96 then
|
||||
price := flt(((trunc(x * 100.0) - 31) div 5) * 4 + 50) / 100.0;
|
||||
else
|
||||
price := 1.0;
|
||||
end if;
|
||||
end func;
|
||||
|
||||
const proc: main is func
|
||||
local
|
||||
var integer: i is 0;
|
||||
begin
|
||||
for i range 0 to 100 do
|
||||
writeln(flt(i) / 100.0 digits 2 <& " " <& computePrice(flt(i) / 100.0) digits 2);
|
||||
end for;
|
||||
end func;
|
||||
21
Task/Price-fraction/Seed7/price-fraction-2.seed7
Normal file
21
Task/Price-fraction/Seed7/price-fraction-2.seed7
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
const array array float: table is [] (
|
||||
[] (0.06, 0.10), [] (0.11, 0.18), [] (0.16, 0.26), [] (0.21, 0.32), [] (0.26, 0.38),
|
||||
[] (0.31, 0.44), [] (0.36, 0.50), [] (0.41, 0.54), [] (0.46, 0.58), [] (0.51, 0.62),
|
||||
[] (0.56, 0.66), [] (0.61, 0.70), [] (0.66, 0.74), [] (0.71, 0.78), [] (0.76, 0.82),
|
||||
[] (0.81, 0.86), [] (0.86, 0.90), [] (0.91, 0.94), [] (0.96, 0.98), [] (1.01, 1.00));
|
||||
|
||||
const func float: computePrice (in float: x) is func
|
||||
result
|
||||
var float: price is 0.0;
|
||||
local
|
||||
var integer: index is 1;
|
||||
begin
|
||||
if x >= 0.0 then
|
||||
while x >= table[index][1] do
|
||||
incr(index);
|
||||
end while;
|
||||
price := table[index][2];
|
||||
else
|
||||
raise RANGE_ERROR;
|
||||
end if;
|
||||
end func;
|
||||
Loading…
Add table
Add a link
Reference in a new issue