March 2014 update
This commit is contained in:
parent
09687c4926
commit
a25938f123
1846 changed files with 21876 additions and 5203 deletions
14
Task/Arithmetic-Complex/COBOL/arithmetic-complex-1.cobol
Normal file
14
Task/Arithmetic-Complex/COBOL/arithmetic-complex-1.cobol
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
$SET SOURCEFORMAT "FREE"
|
||||
$SET ILUSING "System"
|
||||
$SET ILUSING "System.Numerics"
|
||||
class-id Prog.
|
||||
method-id. Main static.
|
||||
procedure division.
|
||||
declare num as type Complex = type Complex::ImaginaryOne()
|
||||
declare results as type Complex occurs any
|
||||
set content of results to ((num + num), (num * num), (- num), (1 / num), type Complex::Conjugate(num))
|
||||
perform varying result as type Complex thru results
|
||||
display result
|
||||
end-perform
|
||||
end method.
|
||||
end class.
|
||||
13
Task/Arithmetic-Complex/Frink/arithmetic-complex.frink
Normal file
13
Task/Arithmetic-Complex/Frink/arithmetic-complex.frink
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
add[x,y] := x + y
|
||||
multiply[x,y] := x * y
|
||||
negate[x] := -x
|
||||
invert[x] := 1/x // Could also use inv[x] or recip[x]
|
||||
conjugate[x] := Re[x] - Im[x] i
|
||||
|
||||
a = 3 + 2.5i
|
||||
b = 7.3 - 10i
|
||||
println["$a + $b = " + add[a,b]]
|
||||
println["$a * $b = " + multiply[a,b]]
|
||||
println["-$a = " + negate[a]]
|
||||
println["1/$a = " + invert[a]]
|
||||
println["conjugate[$a] = " + conjugate[a]]
|
||||
16
Task/Arithmetic-Complex/Rust/arithmetic-complex.rust
Normal file
16
Task/Arithmetic-Complex/Rust/arithmetic-complex.rust
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
extern crate num;
|
||||
|
||||
use num::complex::Cmplx;
|
||||
|
||||
fn main() {
|
||||
let a = Cmplx::new(-4.0, 5.0);
|
||||
let b = Cmplx::new(1.0, 1.0);
|
||||
|
||||
println!("a = {}", a);
|
||||
println!("b = {}", b);
|
||||
println!("a + b = {}", a + b);
|
||||
println!("a * b = {}", a * b);
|
||||
println!("1 / a = {}", Cmplx::new(1.0, 0.0) / a);
|
||||
println!("-a = {}", -a);
|
||||
println!("conj a = {}", a.conj());
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue