Advertisement
electricmaster

Assignment4.jl

Dec 2nd, 2017
644
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Julia 0.56 KB | None | 0 0
  1. const numbers = [75, -18, 216, 21, -6, 352, 39, -68, -318, 182]
  2. const seed = 42
  3.  
  4. function nonrand(i::Int64)
  5.     if(i < 1 || i > length(numbers) + 1)
  6.         throw(BoundsError())
  7.     end
  8.     return numbers[i]
  9. end
  10.  
  11. function random()
  12.     return rand(-999:999)
  13. end
  14.  
  15. x = Array{Int64, 1}(10)
  16. y = Array{Int64, 1}(10)
  17.  
  18. srand(seed)
  19. for i = 1:10
  20.     x[i] = nonrand(i)
  21.     y[i] = random()
  22. end
  23.  
  24. x = sort(x)
  25. y = sort(y)
  26.  
  27. println("\tNONRAND\tRAND")
  28. println("MIN\t$(x[1])\t$(y[1])")
  29. println("MAX\t$(x[10])\t$(y[10])")
  30. println("MEAN\t$(mean(x))\t$(mean(y))")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement