Data update
This commit is contained in:
parent
ed705008a8
commit
0df55f9f24
2196 changed files with 32999 additions and 3075 deletions
|
|
@ -0,0 +1,16 @@
|
|||
print "Please enter 11 numbers :"
|
||||
n[] = number strsplit input " "
|
||||
print ""
|
||||
print "Evaluating f(x) = |x|^0.5 + 5x^3 for the given inputs :"
|
||||
for i = len n[] downto 1
|
||||
r = sqrt abs n[i] + 5 * pow n[i] 3
|
||||
write "f(" & n[i] & ") = "
|
||||
if r > 400
|
||||
print "Overflow!"
|
||||
else
|
||||
print r
|
||||
.
|
||||
.
|
||||
# without this section, the input is interactive
|
||||
input_data
|
||||
10 -1 1 2 3 4 4.3 4.31 4.32 4.32 4.29
|
||||
|
|
@ -5,13 +5,13 @@ public program()
|
|||
{
|
||||
real[] inputs := new real[](11);
|
||||
console.printLine("Please enter 11 numbers :");
|
||||
for(int i := 0, i < 11, i += 1)
|
||||
for(int i := 0; i < 11; i += 1)
|
||||
{
|
||||
inputs[i] := console.readLine().toReal()
|
||||
};
|
||||
|
||||
console.printLine("Evaluating f(x) = |x|^0.5 + 5x^3 for the given inputs :");
|
||||
for(int i := 10, i >= 0, i -= 1)
|
||||
for(int i := 10; i >= 0; i -= 1)
|
||||
{
|
||||
real result := sqrt(abs(inputs[i])) + 5 * power(inputs[i], 3);
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
clear all;close all;clc;
|
||||
|
||||
% Define the function f(x)
|
||||
f = @(x) sqrt(abs(x)) + 5 * x^3;
|
||||
|
||||
% Read a line of input, split it into elements, convert to numbers
|
||||
inputLine = input('', 's');
|
||||
numbers = str2double(strsplit(inputLine));
|
||||
|
||||
% Process each number in reverse order
|
||||
for i = length(numbers):-1:1
|
||||
value = f(numbers(i));
|
||||
if value > 400
|
||||
fprintf('%g: TOO LARGE\n', numbers(i));
|
||||
else
|
||||
fprintf('%g: %g\n', numbers(i), value);
|
||||
end
|
||||
end
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
import "io" for Stdin, Stdout
|
||||
import "/fmt" for Fmt
|
||||
import "./fmt" for Fmt
|
||||
|
||||
var f = Fn.new { |x| x.abs.sqrt + 5*x*x*x }
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue