Advertisement
Guest User

Untitled

a guest
Nov 28th, 2014
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.59 KB | None | 0 0
  1. object PerekluchatelSostoyaniy extends App {
  2.   val spisokPerekluchateley = Array(
  3.     (sostoyanie: Int) => (sostoyanie + 1) % 2,
  4.     (sostoyanie: Int) => math.pow(0, sostoyanie).toInt,
  5.     (sostoyanie: Int) => math.cos(sostoyanie * math.Pi / 2).toInt,
  6.     (sostoyanie: Int) => (math.acos(sostoyanie) / (math.Pi / 2)).toInt,
  7.     (sostoyanie: Int) => (sostoyanie to 0).foldLeft(0)((acc, elem) => acc + 1)
  8.   )
  9.  
  10.   println("Vvedite sostoyanie (1 ili 0):")
  11.   val sostoyanie = readInt
  12.  
  13.   println("Perekluchennoe sostoyanie: " + spisokPerekluchateley(scala.util.Random.nextInt(5))(sostoyanie))
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement